-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
feat: default tgw route table tags (rebased against current HEAD) #49
Conversation
main.tf
Outdated
@@ -33,6 +41,14 @@ resource "aws_ec2_transit_gateway" "this" { | |||
) | |||
} | |||
|
|||
resource "aws_ec2_tag" "this" { | |||
count = var.create_tgw ? length(local.tgw_default_route_table_tags_merged) : 0 |
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.
for_each
is generally a better option, because with count
it will recreate tags when the order changes.
We should aim to use for_each
for new features (like this one).
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.
agreed, however that would require making this resource required as opposed to optional. Since count
and for_each
are mutually exclusive. Making this non-optional potentially opens to door to failed runs, since aws_ec2_transit_gateway.this[0].association_default_route_table_id
is a dependency on of the resource, if aws_ec2_transit_gateway.this
isn't created because someone passed the create_tgw
the module run would also fail.
IMO If we want to do that we should refactor and remove the create_tgw
parameter entirely. But doing that seemed like it was outside the scope of this change.
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.
We can write for_each
to be conditional, too. For example, https://github.com/terraform-aws-modules/terraform-aws-eventbridge/blob/master/main.tf#L166
create_tgw
is important to control creation when calling this module from Terragrunt, for example.
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.
Hmm yeah that could work, let me add it to this branch and re-push!
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.
nice, that worked well! Just pushed an update!
v2.3.0 has been just released. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
This is this same PR #34 just rebased against current master
Motivation and Context
This is a great feature, and IMO much needed
Breaking Changes
This change doesn't break compatibility, however since it uses
count
any change to the tags will generate a bit of resource churn. It might be worth discussing how desirable thecreate_tgw
parameter is in later releases and if we should keep it around.How Has This Been Tested?
Tested against my local dev env.
examples/*
projects