team: mark slug as computed when name changes #757
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This configures Terraform to mark
github_team.*.slug
as computed any timename
changes, ensuring that it shows any resource that is dependent onslug
as requiring an update.I spotted this need when using
terraform import
with an existing team that had a different name than what was declared in configuration. Other resources in the same configuration (team_sync_group_mapping
in my case) that depended on that slug still showed the current slug in the plan. Without this hint fromCustomizeDiff
, Terraform can't know that the computed value ofslug
will be different after the name is updated and the value in state (from the import) should not be used.I used
customdiff.Sequence
as a general pattern here so that additional CustomizeDiffFuncs can be added for other fields. However, it could easily be removed too.A test that has another resource that depends on
slug
provides coverage here. Using another team and sticking aslug
in the description was convenient. Without the customized diff, the test fails:With the custom diff the test passes.