terraform-aws-modules / .github

Meta-GitHub repository for all terraform-aws-modules repositories 🇺🇦
22 stars 30 forks source link

EC2 Tags when connecting to Transit Gateway #27

Closed RSPXIOI closed 1 year ago

RSPXIOI commented 1 year ago

resource "aws_ec2_tag" "default_example" {

count = var.create_vpn_connection && local.tunnel_details_not_specified ? 1 : 0

resource_id = aws_vpn_connection.default[0].transit_gateway_attachment_id key = "Name" value = "local.name_tag" }

resource "aws_ec2_tag" "tunnel_example" {

count = var.create_vpn_connection && local.create_tunnel_with_internal_cidr_only ? 1 : 0

resource_id = aws_vpn_connection.tunnel[0].transit_gateway_attachment_id key = "Name" value = local.name_tag }

resource "aws_ec2_tag" "preshared_example" {

count = var.create_vpn_connection && local.create_tunnel_with_preshared_key_only ? 1 : 0

resource_id = aws_vpn_connection.preshared[0].transit_gateway_attachment_id key = "Name" value = local.name_tag }

resource "aws_ec2_tag" "tunnel_preshared_example" {

count = var.create_vpn_connection && local.tunnel_details_specified ? 1 : 0

resource_id = aws_vpn_connection.tunnel_preshared[0].transit_gateway_attachment_id key = "Name" value = local.name_tag }

jrkalf-cambrian commented 1 year ago

Hi @RSPXIOI,

Please check my PR: https://github.com/terraform-aws-modules/terraform-aws-vpn-gateway/pull/92 I believe this covers your request.

I've made the code a bit more dynamic with a for_each statement and I've added in a merge for the local.name_tag and var.tags to also apply the additional tags.

This is something we needed as well, as we define more global tags ourselves that need to be applied for both cost and project attribution.

antonbabenko commented 1 year ago

This is not the right repository for such issues.

https://github.com/terraform-aws-modules/terraform-aws-vpn-gateway/pull/92 - look here.