Skip to content

Commit

Permalink
add tag for assocation
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Nov 25, 2022
1 parent ee22f10 commit 468396e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
2 changes: 2 additions & 0 deletions vpc-transit-gateway-association/peer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ No modules.
| [aws_ec2_transit_gateway_peering_attachment.attachment_peer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway_peering_attachment) | data source |
| [aws_ec2_transit_gateway_peering_attachment.attachment_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway_peering_attachment) | data source |
| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source |
| [aws_iam_account_alias.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_region.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |

## Inputs
Expand Down
10 changes: 7 additions & 3 deletions vpc-transit-gateway-association/peer/data.network_account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data "aws_arn" "network_account" {
arn = data.aws_caller_identity.network_account.arn
}

# output "network_account" {
# value = data.aws_arn.network_account
# }
data "aws_region" "network_account" {
provider = aws.network_account
}

data "aws_iam_account_alias" "network_account" {
provider = aws.network_account
}
3 changes: 3 additions & 0 deletions vpc-transit-gateway-association/self/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module "vpc_tgw_self" {
| Name | Type |
|------|------|
| [aws_ec2_tag.vpc_sttachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_tag) | resource |
| [aws_ec2_transit_gateway_route_table_association.route_table_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_association) | resource |
| [aws_ec2_transit_gateway_route_table_propagation.vpc_self_common](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation) | resource |
| [aws_ec2_transit_gateway_route_table_propagation.vpc_self_own_rt](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation) | resource |
Expand All @@ -89,7 +90,9 @@ module "vpc_tgw_self" {
| [aws_ec2_transit_gateway_peering_attachment.attachment_peer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway_peering_attachment) | data source |
| [aws_ec2_transit_gateway_peering_attachment.attachment_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway_peering_attachment) | data source |
| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source |
| [aws_iam_account_alias.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_region.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
## Inputs
Expand Down
10 changes: 10 additions & 0 deletions vpc-transit-gateway-association/self/associate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "vpc_attachment" {
)
}

# tag in network account
resource "aws_ec2_tag" "vpc_sttachment" {
provider = aws.self

resource_id = aws_ec2_transit_gateway_vpc_attachment.vpc_attachment.id
key = "Name"
# value = format("%v:%v:%v", data.aws_iam_account_alias.network_account.account_alias,var.vpc_full_name, data.aws_region.network_account.name)
value = format("%v:%v", data.aws_iam_account_alias.network_account.account_alias, var.vpc_full_name)
}

output "vpc_attachment_id" {
description = "Transit Gateway VPC Attachment ID for this VPC"
value = aws_ec2_transit_gateway_vpc_attachment.vpc_attachment.id
Expand Down
10 changes: 7 additions & 3 deletions vpc-transit-gateway-association/self/data.network_account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data "aws_arn" "network_account" {
arn = data.aws_caller_identity.network_account.arn
}

# output "network_account" {
# value = data.aws_arn.network_account
# }
data "aws_region" "network_account" {
provider = aws.network_account
}

data "aws_iam_account_alias" "network_account" {
provider = aws.network_account
}

0 comments on commit 468396e

Please sign in to comment.