Skip to content

Commit

Permalink
Merge pull request #35 from unifio/yl-wip
Browse files Browse the repository at this point in the history
Support adding additional tags
  • Loading branch information
yuhunglin authored Aug 7, 2018
2 parents 5c1b475 + 3498a58 commit 8dda436
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
20 changes: 10 additions & 10 deletions az/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ locals {

# Check to see if NAT gateways are NOT to be provisioned
nat_gateways_not_enabled_check = "${var.nat_gateways_enabled != "true" ? 1 : 0}"

# default subnet tags
default_subnet_tags = [
{
application = "${var.stack_item_fullname}"
managed_by = "terraform"
},
]
}

## Provisions DMZ resources
Expand All @@ -61,11 +69,7 @@ resource "aws_subnet" "dmz" {
map_public_ip_on_launch = "${var.enable_dmz_public_ips}"
vpc_id = "${var.vpc_id}"

tags {
application = "${var.stack_item_fullname}"
managed_by = "terraform"
Name = "${var.stack_item_label}-dmz-${count.index}"
}
tags = "${concat(local.default_subnet_tags, var.additional_subnet_tags, list(map("Name", "${var.stack_item_label}-dmz-${count.index}")))}"
}

### Associates subnet with routing table
Expand Down Expand Up @@ -189,11 +193,7 @@ resource "aws_subnet" "lan" {
cidr_block = "${local.lan_cidrs_override_enabled == "true" ? element(var.lan_cidrs_override,count.index) : cidrsubnet(data.aws_vpc.base.cidr_block,lookup(var.az_cidrsubnet_newbits, local.azs_provisioned_count * local.lans_multiplier),count.index + lookup(var.az_cidrsubnet_offset, local.azs_provisioned_count))}"
vpc_id = "${var.vpc_id}"

tags {
application = "${var.stack_item_fullname}"
managed_by = "terraform"
Name = "${var.stack_item_label}-lan-${count.index}"
}
tags = "${concat(local.default_subnet_tags, var.additional_subnet_tags, list(map("Name", "${var.stack_item_label}-lan-${count.index}")))}"
}

### Provisions routing table
Expand Down
6 changes: 6 additions & 0 deletions az/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "stack_item_label" {
default = "qckstrt"
}

variable "additional_subnet_tags" {
type = "list"
description = "Additional subnet to apply at the subnet level, if any"
default = []
}

## VPC parameters
variable "az_cidrsubnet_newbits" {
type = "map"
Expand Down
14 changes: 9 additions & 5 deletions base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ terraform {
## Set default instance tennancy if not provided
locals {
default_instance_tenancy = "${length(var.instance_tenancy) >= 1 ? "${var.instance_tenancy}" : "default"}"

default_vpc_tags = [
{
application = "${var.stack_item_fullname}"
managed_by = "terraform"
Name = "${var.stack_item_label}-vpc"
},
]
}

## Provisions Virtual Private Cloud (VPC)
Expand All @@ -20,11 +28,7 @@ resource "aws_vpc" "vpc" {
enable_classiclink_dns_support = "${var.enable_classiclink_dns_support}"
assign_generated_ipv6_cidr_block = "${var.assign_generated_ipv6_cidr_block}"

tags {
application = "${var.stack_item_fullname}"
managed_by = "terraform"
Name = "${var.stack_item_label}-vpc"
}
tags = "${concat(local.default_vpc_tags, var.additional_vpc_tags)}"
}

## Provisions Internet gateways
Expand Down
6 changes: 6 additions & 0 deletions base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "stack_item_label" {
default = "qckstrt"
}

variable "additional_vpc_tags" {
type = "list"
description = "Additional tags to apply at the VPC level, if any"
default = []
}

## VPC parameters
variable "assign_generated_ipv6_cidr_block" {
type = "string"
Expand Down

0 comments on commit 8dda436

Please sign in to comment.