Skip to content

Commit

Permalink
Bring up an centos 7 instance and enable ipv6
Browse files Browse the repository at this point in the history
Authored-by: Kevin Yeap <[email protected]>
  • Loading branch information
kyeap-vmware committed Oct 19, 2018
1 parent 92e3811 commit 95f49e4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
25 changes: 20 additions & 5 deletions ipv6.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ provider "aws" {

variable "aws_region" {
type = "string"
default = "us-west-2"
default = "us-east-1"
}

variable "aws_profile" {
Expand All @@ -21,12 +21,12 @@ variable "key_name" {
# Ubuntu AMIs from https://cloud-images.ubuntu.com/locator/ec2/
variable "instance_ami" {
type = "string"
default = "ami-22741f5a" # Ubuntu 18.04 HVM/EBS in us-west-2
default = "ami-9887c6e7" # CentOS 7 (x86_64) - with Updates HVM in us-east-1
}

variable "instance_size" {
type = "string"
default = "t2.nano"
default = "r3.xlarge"
}

data "aws_availability_zones" "available" {}
Expand Down Expand Up @@ -129,7 +129,7 @@ resource "aws_route_table_association" "public_ipv6" {
route_table_id = "${aws_route_table.ipv6_route_table.id}"
}

resource "aws_instance" "ipv6_instance" {
resource "aws_instance" "ipv6_mdw" {
ami = "${var.instance_ami}"
instance_type = "${var.instance_size}"
key_name = "${var.key_name}"
Expand All @@ -140,6 +140,21 @@ resource "aws_instance" "ipv6_instance" {
user_data = "${data.template_file.userdata.rendered}"

tags {
Name = "ipv6_instance"
Name = "ipv6_mdw"
}
}

resource "aws_instance" "ipv6_sdw1" {
ami = "${var.instance_ami}"
instance_type = "${var.instance_size}"
key_name = "${var.key_name}"
subnet_id = "${aws_subnet.public_ipv6.id}"

vpc_security_group_ids = ["${aws_security_group.ipv6_security.id}"]
associate_public_ip_address = true
user_data = "${data.template_file.userdata.rendered}"

tags {
Name = "ipv6_sdw1"
}
}
38 changes: 38 additions & 0 deletions userdata.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
#!/bin/bash

# Add any commands that should be run on instance creation

cat > /etc/cloud/cloud.cfg.d/99-custom-networking.cfg <<EOF
network:
version: 1
config:
- type: physical
name: ens3
subnets:
- type: dhcp
- type: dhcp6
EOF

cat > /tmp/gpadmin_id_rsa <<EOF
-----BEGIN RSA PRIVATE KEY-----
# Add user private key here
-----END RSA PRIVATE KEY-----
EOF

echo "kernel.sem = 250 512000 100 2048" >> /etc/sysctl.conf

mkdir -p /etc/security/limits.d
echo '* soft core unlimited' >> /etc/security/limits.d/99-core.conf
echo '* hard core unlimited' >> /etc/security/limits.d/99-core.conf

echo 'gpadmin soft nproc 131072' >> /etc/security/limits.d/gpadmin-limits.conf
echo 'gpadmin hard nproc 131072' >> /etc/security/limits.d/gpadmin-limits.conf
echo 'gpadmin soft nofile 65536' >> /etc/security/limits.d/gpadmin-limits.conf
echo 'gpadmin hard nofile 65536' >> /etc/security/limits.d/gpadmin-limits.conf

useradd -m gpadmin
mkdir /home/gpadmin/.ssh
cp /tmp/gpadmin_id_rsa /home/gpadmin/.ssh/id_rsa
cp /home/centos/.ssh/authorized_keys /home/gpadmin/.ssh/
chown -R gpadmin:gpadmin /home/gpadmin/.ssh
chmod 600 /home/gpadmin/.ssh/id_rsa

reboot

0 comments on commit 95f49e4

Please sign in to comment.