Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Oct 13, 2022
1 parent cbc2f89 commit db940fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
9 changes: 5 additions & 4 deletions vpc-transit-gateway-association/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ module "vpc_tgw" {

| Name | Source | Version |
|------|--------|---------|
| <a name="module_routing_attachment"></a> [routing\_attachment](#module\_routing\_attachment) | git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//routing | tf-upgrade |
| <a name="module_routing_attachment_ipv4"></a> [routing\_attachment\_ipv4](#module\_routing\_attachment\_ipv4) | git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//routing | tf-upgrade |

## Resources

| Name | Type |
|------|------|
| [aws_route.gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [aws_route.gateway_ipv4](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source |
| [aws_arn.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source |
| [aws_availability_zone.zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
| [aws_availability_zones.zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_caller_identity.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_ec2_managed_prefix_list.tgw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_managed_prefix_list) | data source |
| [aws_ec2_managed_prefix_list.tgw_ipv4](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_managed_prefix_list) | data source |
| [aws_ec2_managed_prefix_lists.tgw_ipv4](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_managed_prefix_lists) | data source |
| [aws_ec2_transit_gateway.gateway_peer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway) | data source |
| [aws_ec2_transit_gateway.gateway_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway) | data source |
| [aws_ec2_transit_gateway_route_table.route_tables_peer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway_route_table) | data source |
Expand All @@ -68,7 +69,7 @@ module "vpc_tgw" {
| <a name="input_network_account_profile"></a> [network\_account\_profile](#input\_network\_account\_profile) | AWS profile of the source account sharing the VPC resources | `string` | n/a | yes |
| <a name="input_override_prefixes"></a> [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no |
| <a name="input_private_subnets_ids"></a> [private\_subnets\_ids](#input\_private\_subnets\_ids) | List of private subnet objects including: subnet, label, availability\_zone, id | <pre>list(object({<br> subnet = string<br> label = string<br> availability_zone = string<br> id = string<br> }))</pre> | `[]` | no |
| <a name="input_route_prefix_list_name"></a> [route\_prefix\_list\_name](#input\_route\_prefix\_list\_name) | Shared prefix list name used for routing to TGW. It is comprised of all of the network CIDR blocks in AWS using TGW. | `string` | `"transit-gateway.prod.ipv4"` | no |
| <a name="input_route_prefix_list_name"></a> [route\_prefix\_list\_name](#input\_route\_prefix\_list\_name) | Shared prefix list name used for routing to TGW. It is comprised of all of the network CIDR blocks in AWS using TGW. | `string` | `"transit-gateway.prod"` | no |
| <a name="input_route_table_label"></a> [route\_table\_label](#input\_route\_table\_label) | Route table lable for the attachment subnets | `string` | `"attachment"` | 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_transit_gateway_environment"></a> [transit\_gateway\_environment](#input\_transit\_gateway\_environment) | Transit Gateway Environment (aka, VRF) to which to connnect this VPC | `string` | n/a | yes |
Expand Down
17 changes: 11 additions & 6 deletions vpc-transit-gateway-association/routing.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "routing_attachment" {
module "routing_attachment_ipv4" {
source = "git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//routing?ref=tf-upgrade"
vpc_id = var.vpc_id

Expand All @@ -23,19 +23,24 @@ module "routing_attachment" {
)
}

data "aws_ec2_managed_prefix_list" "tgw" {
data "aws_ec2_managed_prefix_lists" "tgw_ipv4" {
filter {
name = "prefix-list-name"
values = [var.route_prefix_list_name]
values = [var.route_prefix_list_name, format("%v.ipv4", var.route_prefix_list_name)]
}
}

resource "aws_route" "gateway" {
for_each = module.routing.private_route_table_ids
data "aws_ec2_managed_prefix_list" "tgw_ipv4" {
for_each = data.aws_ec2_managed_prefix_lists.tgw_ipv4.ids
id = each.key
}

resource "aws_route" "gateway_ipv4" {
for_each = module.routing_ipv4.private_route_table_ids

route_table_id = each.value
# destination_cidr_block = "10.128.0.0/16"
destination_prefix_list_id = data.aws_ec2_managed_prefix_list.tgw.id
destination_prefix_list_id = one([for k, v in data.aws_ec2_managed_prefix_list.tgw_ipv4 : k if v.address_family == "IPv4"])
transit_gateway_id = data.aws_ec2_transit_gateway.gateway_east.id

depends_on = [aws_ec2_transit_gateway_vpc_attachment.vpc_attachment]
Expand Down
2 changes: 1 addition & 1 deletion vpc-transit-gateway-association/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ variable "route_table_label" {
variable "route_prefix_list_name" {
description = "Shared prefix list name used for routing to TGW. It is comprised of all of the network CIDR blocks in AWS using TGW."
type = string
default = "transit-gateway.prod.ipv4"
default = "transit-gateway.prod"
}

0 comments on commit db940fe

Please sign in to comment.