-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
r/aws_launch_template: Set latest version computed on change #5250
r/aws_launch_template: Set latest version computed on change #5250
Conversation
Hi @gordonbondon! 👋 Thanks for submitting this! While its not documented in the Extending Terraform section of the website quite yet, we generally recommend avoiding any sort of "magic" logic with the schema. Usually this is for readability and long-term maintenance among other things. Using your acceptance test update, I was able to verify a simpler change using CustomizeDiff: customdiff.Sequence(
customdiff.ComputedIf("latest_version", func(diff *schema.ResourceDiff, meta interface{}) bool {
for _, changedKey := range diff.GetChangedKeysPrefix("") {
switch changedKey {
case "name", "name_prefix", "description", "default_version", "latest_version":
continue
default:
return true
}
}
return false
}),
),
What do you think? |
@bflad nice, I didn't know about this magic GetChangeKeysPrefix. I'll update my pr to use it. It will look much better this way. |
@bflad i've updated my PR according to your comment. Thanksfor the tip! Acc tests after 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.
LGTM, thanks @gordonbondon! 🚀
9 tests passed (all tests)
=== RUN TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (7.16s)
=== RUN TestAccAWSLaunchTemplate_nonBurstable
--- PASS: TestAccAWSLaunchTemplate_nonBurstable (7.19s)
=== RUN TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (7.36s)
=== RUN TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (7.80s)
=== RUN TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (8.04s)
=== RUN TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (8.95s)
=== RUN TestAccAWSLaunchTemplate_networkInterface
--- PASS: TestAccAWSLaunchTemplate_networkInterface (10.93s)
=== RUN TestAccAWSLaunchTemplate_tags
--- PASS: TestAccAWSLaunchTemplate_tags (12.85s)
=== RUN TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (48.95s)
🎉 |
This has been released in version 1.30.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Proposed changes:
latest_version
as computed on any filed change except name and description. Currently on every change to launch template new version is created. But this version is set to state only after apply is done. So other resources that uselatest_version
will pick up the change only on second apply.Can be used as a workaround for #4655 , if later resources use
latest_version
inlaunch_template
specification.Output from acceptance testing:
UPD: Rebased.