Terraform template - AWS VPC
Problem this snippet solves: Terraform template - AWS VPC Code : resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" enable_dns_support = true enable_dns_hostnames = true tags { Name = "main" } } resource "aws_subnet" "management" { vpc_id = "${aws_vpc.main.id}" cidr_block = "10.0.0.0/24" tags { Name = "management-subnet" } } resource "aws_subnet" "external" { vpc_id = "${aws_vpc.main.id}" cidr_block = "10.0.1.0/24" availability_zone = "${aws_subnet.management.availability_zone}" tags { Name = "external-subnet" } } resource "aws_subnet" "internal" { vpc_id = "${aws_vpc.main.id}" cidr_block = "10.0.2.0/24" availability_zone = "${aws_subnet.management.availability_zone}" tags { Name = "internal-subnet" } } resource "aws_subnet" "ha" { vpc_id = "${aws_vpc.main.id}" cidr_block = "10.0.3.0/24" availability_zone = "${aws_subnet.management.availability_zone}" tags { Name = "ha-subnet" } } resource "aws_internet_gateway" "gw" { vpc_id = "${aws_vpc.main.id}" tags { Name = "internet-gateway" } } resource "aws_route_table" "management" { vpc_id = "${aws_vpc.main.id}" tags { Name = "management route table" } } resource "aws_route_table" "external" { vpc_id = "${aws_vpc.main.id}" route { cidr_block = "0.0.0.0/0" gateway_id = "${aws_internet_gateway.gw.id}" } tags { Name = "external route table" } } resource "aws_route_table" "internal" { vpc_id = "${aws_vpc.main.id}" tags { Name = "internal route table" } } resource "aws_route_table" "ha" { vpc_id = "${aws_vpc.main.id}" tags { Name = "ha route table" } } resource "aws_route" "management-def" { route_table_id = "${aws_route_table.management.id}" destination_cidr_block = "0.0.0.0/0" gateway_id = "${aws_internet_gateway.gw.id}" } #resource "aws_route" "external-def" { # route_table_id = "${aws_route_table.external.id}" # destination_cidr_block = "0.0.0.0/0" # gateway_id = "${aws_internet_gateway.gw.id}" #} resource "aws_route_table_association" "management" { subnet_id = "${aws_subnet.management.id}" route_table_id = "${aws_route_table.management.id}" } resource "aws_route_table_association" "external" { subnet_id = "${aws_subnet.external.id}" route_table_id = "${aws_route_table.external.id}" } resource "aws_route_table_association" "internal" { subnet_id = "${aws_subnet.internal.id}" route_table_id = "${aws_route_table.internal.id}" } resource "aws_route_table_association" "ha" { subnet_id = "${aws_subnet.ha.id}" route_table_id = "${aws_route_table.ha.id}" } resource "aws_security_group" "allow_all" { name = "allow_all" description = "Allow all inbound traffic" vpc_id = "${aws_vpc.main.id}" ingress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } }329Views0likes0CommentsTerraform template - AWS Cloud-Init
Problem this snippet solves: Terraform template - AWS Cloud-Init Code : #cloud-config # vim: syntax=yaml # # This is the configuration syntax that the write_files module # will know how to understand. encoding can be given b64 or gzip or (gz+b64). # The content will be decoded accordingly and then written to the path that is # provided. # # Note: Content strings here are truncated for example purposes. write_files: - content: | /usr/bin/tmsh modify auth user admin shell bash echo "Executed!" >> /root/example path: /root/example runcmd: - chmod 755 /root/example - /root/example - [ /root/example ]293Views0likes0CommentsTerraform template - AWS variables
Problem this snippet solves: Terraform template - AWS variables Code : variable "ha_enabled" { default = "0" } variable "region" { default = "us-east-1" } provider "aws" { access_key = "access" secret_key = "secret" region = "${var.region}" } variable "dut-ami" { default = { us-east-1 = "ami-key" } }272Views0likes0CommentsTerraform template - AWS autoscaling
Problem this snippet solves: Terraform template - AWS autoscaling Code : resource "aws_launch_configuration" "lc_conf" { name_prefix = "lc-example-" image_id = "ami-id" instance_type = "t2.micro" lifecycle { create_before_destroy = false } } resource "aws_autoscaling_group" "asg_group" { name = "asg_group" launch_configuration = "${aws_launch_configuration.lc_conf.name}" max_size = 2 min_size = 0 desired_capacity = 0 vpc_zone_identifier = ["${aws_subnet.internal.id}"] availability_zones = ["${aws_subnet.management.availability_zone}"] wait_for_capacity_timeout = 0 lifecycle { create_before_destroy = false } }250Views0likes0CommentsTerraform template - AWS instance
Problem this snippet solves: Terraform template - AWS instance Code : resource "aws_instance" "f5" { ami = "ami-id" instance_type = "m3.xlarge" associate_public_ip_address = true private_ip = "10.0.0.21" availability_zone = "${aws_subnet.management.availability_zone}" subnet_id = "${aws_subnet.management.id}" security_groups = ["${aws_security_group.allow_all.id}"] vpc_security_group_ids = ["${aws_security_group.allow_all.id}"] #user_data = "${file("cloud-config.yaml")}" key_name = "key-name" root_block_device { delete_on_termination = true } tags { Name = "f5" License = "License" } }243Views0likes0Comments