Created
February 14, 2020 09:05
-
-
Save law/26443ca3c1f511db75d207be4e0a9ce8 to your computer and use it in GitHub Desktop.
Example of what I DONT want to do in TF
This file contains 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_id" { | |
description = "VPC where the subnets to create" | |
} | |
variable "igw_id" { | |
description = "ID of the associated Internet gateway of the vpc" | |
} | |
variable "cidr_list_public" { | |
description = "List of cidrs to use for the public subnets" | |
type = "list" | |
} | |
variable "cidr_list_private" { | |
description = "List of cidrs to use for the private subnets" | |
type = "list" | |
} | |
variable "subnet_azs" { | |
description = "List of AZ's to use for the subnets" | |
type = "list" | |
} | |
aws_region = "eu-central-1" | |
tags = { | |
name = ""foobar" | |
} | |
vpc_name = "foobar" | |
vpc_cidr = "172.1.0.0/16" | |
k8s_enabled = true | |
cidr_list_public = ["172.1.0.0/24", "172.1.1.0/24"] | |
cidr_list_private = ["172.1.3.0/24", "172.1.4.0/24"] | |
subnet_azs = ["a", "b"] | |
resource "aws_subnet" "sn_public" { | |
count = length(var.cidr_list_public) | |
vpc_id = var.vpc_id | |
cidr_block = var.cidr_list_public[count.index] | |
availability_zone = "${var.aws_region}${var.subnet_azs[count.index]}" | |
tags = merge(var.tags, { Name = "SN-Public-${var.tags.Name}-${var.tags.Environment}-${count.index + 1}" }) | |
} | |
resource "aws_subnet" "sn_private" { | |
count = length(var.cidr_list_private) | |
vpc_id = var.vpc_id | |
cidr_block = var.cidr_list_private[count.index] | |
availability_zone = "${var.aws_region}${var.subnet_azs[count.index]}" | |
tags = merge(var.tags, { Name = "SN-Private-${var.tags.Name}-${var.tags.Environment}-${count.index + 1}" }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment