This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkfs.ext4 /dev/xvdh | |
| mount /dev/xvdh /mnt | |
| echo /dev/xvdh /mnt defaults,nofail 0 2 >> /etc/fstab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vpc_cidr = "10.0.0.0/16" | |
| public_cidrs | |
| = [ | |
| "10.0.1.0/24", | |
| "10.0.2.0/24" | |
| ] | |
| private_cidrs | |
| = [ | |
| "10.0.3.0/24", | |
| "10.0.4.0/24" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| variable "vpc_cidr" {} | |
| variable "public_cidrs" { | |
| type = "list" | |
| } | |
| variable "private_cidrs" { | |
| type = "list" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module "vpc_networking" { | |
| source = "./vpc_networking" | |
| vpc_cidr = "${var.vpc_cidr}" | |
| public_cidrs = "${var.public_cidrs}" | |
| private_cidrs = "${var.private_cidrs}" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| variable "vpc_cidr" { | |
| default = "10.0.0.0/16" | |
| } | |
| variable "public_cidrs" { | |
| type = "list" | |
| default = ["10.0.1.0/24","10.0.2.0/24"] | |
| } | |
| variable "private_cidrs" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ terraform apply | |
| data.aws_availability_zones.available: Refreshing state... | |
| An execution plan has been generated and is shown below. | |
| Resource actions are indicated with the following symbols: | |
| + create | |
| Terraform will perform the following actions: | |
| + module.vpc_networking.aws_default_route_table.private_route |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ terraform plan | |
| Refreshing Terraform state in-memory prior to plan... | |
| The refreshed state will be used to calculate this plan, but will not be | |
| persisted to local or remote state storage. | |
| data.aws_availability_zones.available: Refreshing state... | |
| ------------------------------------------------------------------------ | |
| An execution plan has been generated and is shown below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ terraform init | |
| Initializing modules... | |
| - module.vpc_networking | |
| Getting source "./networking" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ingress Security Port 22 | |
| resource "aws_security_group_rule" "ssh_inbound_access" { | |
| from_port = 22 | |
| protocol = "tcp" | |
| security_group_id = "${aws_security_group.test_sg.id}" | |
| to_port = 22 | |
| type = "ingress" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Associate Public Subnet with Public Route Table | |
| resource "aws_route_table_association" "public_subnet_assoc" { | |
| count = "${aws_subnet.public_subnet.count}" | |
| route_table_id = "${aws_route_table.public_route.id}" | |
| subnet_id = "${aws_subnet.public_subnet.*.id[count.index]}" | |
| depends_on = ["aws_route_table.public_route", "aws_subnet.public_subnet"] | |
| } | |
| # Associate Private Subnet with Private Route Table | |
| resource "aws_route_table_association" "private_subnet_assoc" { |