Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3 from rackspace-infrastructure-automation/az-patch
Browse files Browse the repository at this point in the history
Dynamically lanuch subnets into multiple AZs
  • Loading branch information
skenmy authored Sep 20, 2017
2 parents 26372f6 + b09319a commit a07054d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
data "aws_availability_zones" "available" {
state = "available"
}

### AWS VPC
resource "aws_vpc" "vpc" {
cidr_block = "${var.vpc_cidr_range}"
Expand Down Expand Up @@ -26,9 +30,10 @@ resource "aws_internet_gateway" "internet" {
### Private Subnets
# Loop over this as many times as necessary to create the correct number of Private Subnets
resource "aws_subnet" "private_subnet" {
count = "${var.availability_zones_count}"
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${element(var.private_subnets, count.index)}"
count = "${var.availability_zones_count}"
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${element(var.private_subnets, count.index)}"
availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}"

tags {
Environment = "${var.environment}"
Expand All @@ -41,9 +46,10 @@ resource "aws_subnet" "private_subnet" {
### Public Subnets
# Loop over this as many times as necessary to create the correct number of Public Subnets
resource "aws_subnet" "public_subnet" {
count = "${var.availability_zones_count}"
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${element(var.public_subnets, count.index)}"
count = "${var.availability_zones_count}"
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${element(var.public_subnets, count.index)}"
availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}"

tags {
Environment = "${var.environment}"
Expand Down

0 comments on commit a07054d

Please sign in to comment.