Skip to content

Instantly share code, notes, and snippets.

@alexjurkiewicz
Created February 21, 2018 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexjurkiewicz/c62791efcbf103911c67ab98f765bd01 to your computer and use it in GitHub Desktop.
Save alexjurkiewicz/c62791efcbf103911c67ab98f765bd01 to your computer and use it in GitHub Desktop.
Cloudformation vs Terraform
resources:
app_subnet_1:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: !Select: [ 0, !Ref subnet_azs ]
CidrBlock: !Select: [ 0, !Ref subnet_cidrs ]
Tags:
- Key: environment
Value: !Ref workspace
- Key: division
Value: tech
- Key: Name
Value: !Sub
- AppSubnetAZ1-${workspace}
- { workspace: !Ref workspace }
VpcId: !Ref vpc_id
app_subnet_2:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: !Select: [ 1, !Ref subnet_azs ]
CidrBlock: !Select: [ 1, !Ref subnet_cidrs ]
Tags:
- Key: environment
Value: !Ref workspace
- Key: division
Value: tech
- Key: Name
Value: !Sub
- AppSubnetAZ2-${workspace}
- { workspace: !Ref workspace }
VpcId: !Ref vpc_id
resource "aws_subnet" "app" {
count = "${length(var.subnet_cidrs)}"
vpc_id = "${var.vpc_id}"
cidr_block = "${var.subnet_cidrs[count.index]}"
availability_zone = "${var.subnet_azs[count.index]}"
tags {
environment = "${terraform.workspace}"
division = "tech"
Name = "AppSubnetAZ${count.index+1}-${terraform.workspace}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment