Skip to content
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

Merged
merged 4 commits into from
May 19, 2021

Conversation

tfhartmann
Copy link
Collaborator

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 the create_tgw parameter is in later releases and if we should keep it around.

How Has This Been Tested?

Tested against my local dev env.

  • I have tested and validated these changes using one or more of the provided examples/* projects

@tfhartmann tfhartmann linked an issue May 19, 2021 that may be closed by this pull request
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
Copy link
Member

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).

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

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!

@antonbabenko antonbabenko merged commit b655e72 into master May 19, 2021
@antonbabenko antonbabenko deleted the tfhartmann-default-tgw-route-table-tags branch May 19, 2021 19:40
@antonbabenko
Copy link
Member

v2.3.0 has been just released.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default Transit Gateway Route Table tags
3 participants