Skip to content

Commit

Permalink
enable tgw tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Mar 20, 2023
1 parent f6f8251 commit c2cc2db
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,7 @@
- flowlogs
- remove iam_role_arn for s3 log destinations to avoid this error:
Error: creating Flow Log (vpc-0f791ea1e2bb46924): InvalidParameter: DeliverLogsPermissionArn is not applicable for s3 delivery

* 2.6.2 -- 2023-03-20
- tag-shared-vpc-resources
- enable tgw tagging by default, which works now
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
_module_version = "2.6.1"
_module_version = "2.6.2"
_module_names = {
"_main_" = "aws-vpc-setup"

Expand Down
8 changes: 5 additions & 3 deletions examples/full-setup-tf-upgrade/apps/dns/tf-run.data
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
VERSION 1.1.2
VERSION 1.1.3
REMOTE-STATE
COMMAND tf-directory-setup.py -l none -f
COMMAND setup-new-directory.sh
COMMAND tf-init -upgrade

# LINKTOP includes.d/ENVIRONMENT/variables.application_tags.auto.tfvars .
LINKTOP includes.d/variables.application_tags.tf .
LINKTOP includes.d/variables.application_tags.tf
LINKTOP includes.d/prod/variables.application_tags.auto.tfvars
LINK variables.vpc.tf
LINK variables.vpc.auto.tfvars

ALL
COMMAND tf-directory-setup.py -l s3
7 changes: 2 additions & 5 deletions examples/full-setup-tf-upgrade/apps/dns/versions.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.0"
}
infoblox = {
source = "infobloxopen/infoblox"
version = ">= 2.1.0"
version = ">= 4.0"
}
}
}
6 changes: 4 additions & 2 deletions examples/full-setup-tf-upgrade/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ output "vpc_info" {

output "vpn_tunnel_endpoints" {
description = "VPN Tunnel Endpoint IP Addresses"
value = module.vpn.vpn_tunnel_endpoints
# value = module.vpn.vpn_tunnel_endpoints
value = try(module.vpn[0].vpn_tunnel_endpoints, null)
}

output "vpn_labels" {
description = "VPN Label for Description field of Endpoint device (Cisco ASR)"
value = module.vpn.vpn_labels
# value = module.vpn.vpn_labels
value = try(module.vpn[0].vpn_labels, null)
}

output "security_groups" {
Expand Down
7 changes: 2 additions & 5 deletions tag-shared-vpc-resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ This reads tags and updates them in the local account and region from these reso
* subnets
* route-tables
* network-acls

These resources are not compatible for sharing. AWS does not support remote (i.e., in a shared to account) tagging:

* transit-gateway

## How it works
Expand Down Expand Up @@ -51,7 +48,7 @@ module "tag_shared" {
### tag_enabled_route_tables = true
### tag_enabled_subnets = true
### tag_enabled_network_acls = true
### tag_enabled_transit_gateway = false
### tag_enabled_transit_gateway = true
}
```

Expand Down Expand Up @@ -190,7 +187,7 @@ No modules.
| <a name="input_tag_enabled_network_acls"></a> [tag\_enabled\_network\_acls](#input\_tag\_enabled\_network\_acls) | Flag to tag or not tag shared Network ACLs | `bool` | `true` | no |
| <a name="input_tag_enabled_route_tables"></a> [tag\_enabled\_route\_tables](#input\_tag\_enabled\_route\_tables) | Flag to tag or not tag shared VPC route tables | `bool` | `true` | no |
| <a name="input_tag_enabled_subnets"></a> [tag\_enabled\_subnets](#input\_tag\_enabled\_subnets) | Flag to tag or not tag shared VPC subnets | `bool` | `true` | no |
| <a name="input_tag_enabled_transit_gateway"></a> [tag\_enabled\_transit\_gateway](#input\_tag\_enabled\_transit\_gateway) | Flag to tag or not tag shared VPC Transit Gateway (not currently possible in AWS; this has no effect) | `bool` | `false` | no |
| <a name="input_tag_enabled_transit_gateway"></a> [tag\_enabled\_transit\_gateway](#input\_tag\_enabled\_transit\_gateway) | Flag to tag or not tag shared VPC Transit Gateway (not currently possible in AWS; this has no effect) | `bool` | `true` | no |
| <a name="input_tag_enabled_vpcs"></a> [tag\_enabled\_vpcs](#input\_tag\_enabled\_vpcs) | Flag to tag or not tag shared VPCs | `bool` | `true` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no |
| <a name="input_vpc_environment"></a> [vpc\_environment](#input\_vpc\_environment) | VPC environment purpose (infrastructure, common, shared, dev, stage, ite, prod) | `string` | `null` | no |
Expand Down
5 changes: 1 addition & 4 deletions tag-shared-vpc-resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
* * subnets
* * route-tables
* * network-acls
*
* These resources are not compatible for sharing. AWS does not support remote (i.e., in a shared to account) tagging:
*
* * transit-gateway
*
* ## How it works
Expand Down Expand Up @@ -52,7 +49,7 @@
* ### tag_enabled_route_tables = true
* ### tag_enabled_subnets = true
* ### tag_enabled_network_acls = true
* ### tag_enabled_transit_gateway = false
* ### tag_enabled_transit_gateway = true
* }
* ```
*
Expand Down
7 changes: 4 additions & 3 deletions tag-shared-vpc-resources/tag-transit-gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ data "aws_ec2_transit_gateway" "transit_gateway" {
## }

locals {
_tgw_enabled = var.tag_enabled_transit_gateway ? false : false
_tgw_enabled = var.tag_enabled_transit_gateway
_transit_gateway_tags = local._tgw_enabled ? { format("%v", data.aws_ec2_transit_gateway.transit_gateway[0].id) = data.aws_ec2_transit_gateway.transit_gateway[0] } : {}
transit_gateway_tags = { for k, v in local._transit_gateway_tags : k => merge(v.tags, { "boc:vpc:owner_id" = v.owner_id }) }
transit_gateway_tags_map = flatten([for k, v in local.transit_gateway_tags : [for tk, tv in v : { label = format("%v__%v", k, tk), transit_gateway_id = k, key = tk, value = tv }]])
}

resource "aws_ec2_tag" "transit_gateway" {
provider = aws
for_each = false ? { for t in local.transit_gateway_tags_map : t.label => t } : {}
for_each = { for t in local.transit_gateway_tags_map : t.label => t }

resource_id = each.value.transit_gateway_id
key = each.value.key
Expand All @@ -35,4 +35,5 @@ resource "aws_ec2_tag" "transit_gateway" {
## on tag-transit-gateway.tf line 19, in resource "aws_ec2_tag" "transit_gateway":
## 19: resource "aws_ec2_tag" "transit_gateway" {
##
##
## 20230320
## this works now!!
2 changes: 1 addition & 1 deletion tag-shared-vpc-resources/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ variable "tag_enabled_network_acls" {
variable "tag_enabled_transit_gateway" {
description = "Flag to tag or not tag shared VPC Transit Gateway (not currently possible in AWS; this has no effect)"
type = bool
default = false
default = true
}

0 comments on commit c2cc2db

Please sign in to comment.