-
-
Notifications
You must be signed in to change notification settings - Fork 234
feat!: Refactor count
/lists
into for_each
/maps
#113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat!: Refactor count
/lists
into for_each
/maps
#113
Conversation
To avoid downtime when adding/removing attachments. With the previous approach, any new or removed attachments would cause the attachment routes to be deleted and re-created according to the new order.
And unifying peering/VPC attachments under one parameter, VPC attachments are filtered out of the parameter to create the VPC attachement resources.
For fetching attachment details. Add VPC attachment accepter resource to avoid the need for "auto-accept shared attachments" when sharing via RAM.
When route destinations are defined
With composite keys to allow associating/propagating custom route tables.
This PR has been automatically marked as stale because it has been open 30 days |
count
/lists
into for_each
/maps
@bryantbiggs anything I can help with to move this along? |
Could we have a separate PR for adding flow logs? They're quite useful, and it's a shame they're "stuck" in this PR. |
…ws-transit-gateway into significant-refactor
af580c7
to
03c7e76
Compare
03c7e76
to
8f94997
Compare
…ws-transit-gateway into significant-refactor
Does it make sense to change the behavior of the route-table submodule to decouple the associations from the propagations? I see the only way to create route_table_propagations is with: associations = {
vpc1 = {
transit_gateway_attachment_id = module.transit_gateway.vpc_attachments["vpc1"].id
propagate_route_table = true
}
vpc2 = {
transit_gateway_attachment_id = module.transit_gateway.vpc_attachments["vpc2"].id
propagate_route_table = true
}
} but attachments can only be associated to one route table but propagated to multiple route tables. |
variable "vpc_routes" { | ||
description = "A map of VPC routes to create in the route table provided" | ||
type = map(object({ | ||
route_table_id = string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make route_table_id
and destination_cidr_block
lists instead of a single value? in most cases there are multiple route tables that need routes to the transit gateway, and multiple cidr blocks adds flexibility too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely! any details on the usage would be appreciated - Anton and I heavily use various services so we are quite familiar with them, but on something like this module, we're mostly just "Terraform experts" and have less insight into how folks use TGW or how they want to configure TGW using this module. That insight is valuable in helping design the module to support those use cases (where possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryantbiggs good to know :)
We're trying to use the module to create infra a lot like this
We are trying to setup transit gateways so we can route OU VPCs to our VPN. We would like to connect organizational units using transit gateway.
Details
We are using AWS organizations. We have a network service account and we have "spoke" accounts as well.
A simplified network map, which only includes nonprod (excludes prod and uat)
https://viewer.diagrams.net/?tags=%7B%7D&lightbox=1&highlight=B3B3B3&edit=_blank&layers=1&nav=1#G1BsHvhzBNZI_-grnqDZNiJv6dCk_A1K8-#%7B%22pageId%22%3A%22-E4dg9jivi15Yi2I4Ksi%22%7D
Our goal was to create a single tgw in each of the regions we use in the network service account. Each transit gateway would have three routing tables called prod, nonpod, and UAT.
Within the network service account we would also create three VPCs called prod, nonprod, and UAT. Each of these VPC subnets would attach to the tgw and associate with the route table of the same name.
We also created a RAM share for our OU VPCs, like sandbox.
The problems
Maybe I've misunderstood something, but I think the multi account example could be improved? It does not make use of the non-default route table. In my experience the use of the non-default route table is more complex. A working example would be helpful.
We are not currently able to manage multiple tgw route tables using the module as it is.
Managing spoke attachments (eg sandbox vpc in a different OU) seems opaque within the module. I can create the attachment in the sandbox OU using the module.
EDIT
Removing this observation: But I don't think I can use the module in the network service account to manage the sandbox attachment association/propagation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience, using terraform to manage spoke attachments in different OU that do not use the default route table requires a specific configuration.. But maybe I've missed some critical documentation? I don't think I've seen this use case documented anywhere?
terraform apply 1
- TF provider account 1: Create tgw and disable default route table association and propagation, RAM share it with other OU
- TF provider account 1: Create tgw route tables for tgw
- TF provider account 1: Create tgw attachment association & route propagation for VPCs within account 1
terraform apply 2
- TF provider account 2: Create tgw attachment
- TF provider alias to account 1: Create tgw attachment association & route propagation
It would be great if there were a module that handled the second apply.
The critical part is gracefully supporting calling out to the OU where the route table lives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryantbiggs here's an example that demonstrates how we handle terraform apply number 2 described above (spoiler we settled on a provider alias using a different profile)
https://gist.github.com/flah00/fa840591fbb6b131f2c23d020bdc9c30
@ronaldour it seems like this branch is seeing some activity again. |
@flah00 well I'm not part of the maintainers but happy to help with anything to move this forward. @bryantbiggs anything we can help improve here? |
I've been working on an opinionated refactor using this as the base. I focused on simplifying how de module is used since Transit Gateways are fairly complex. https://github.com/ronaldour/terraform-aws-transit-gateway/tree/refactor
If you want to give it a try, feedback is welcome. Check out the Examples |
we'll proceed once AWS provider v6 arrives - this was originally meant to arrive in April but seems to be taking a bit longer |
Description
Motivation and Context
This module was missing quite a few features that are necessary for true multi-account operation, as well as operational concerns like logging.
vpc_attachments[].vpc_route_table_ids
#111Breaking Changes
This PR includes breaking changes due to changes in data structures. The changes to data structures (converting lists/sets to maps, mostly) were necessary to prevent downtime during applies due to deleting/re-creating routes.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull requestI am running my refactor in production currently, using one AWS account as the hub, and several other AWS accounts as the spokes.