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

r/aws_instance: launch_template Remove unnecessary api calls #20357

Conversation

gordonbondon
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

My PR #10807 accidentally introduced two regressions related to instance usage when launch template does not yet exist, or was deleted. This PR addresses those two issues.

Closes #20331
Closes #20287

Output from acceptance testing:

$ → make testacc TEST=./aws TESTARGS='-run=TestAccAWSInstance_LaunchTemplate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSInstance_LaunchTemplate -timeout 180m
=== RUN   TestAccAWSInstance_LaunchTemplate_basic
=== PAUSE TestAccAWSInstance_LaunchTemplate_basic
=== RUN   TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== PAUSE TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== RUN   TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== PAUSE TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== CONT  TestAccAWSInstance_LaunchTemplate_basic
=== CONT  TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== CONT  TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_SwapIDAndName
--- PASS: TestAccAWSInstance_LaunchTemplate_OverrideTemplate (106.95s)
--- PASS: TestAccAWSInstance_LaunchTemplate_basic (142.57s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SwapIDAndName (177.02s)
--- PASS: TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion (182.85s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SetSpecificVersion (206.90s)
--- PASS: TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion (213.68s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	216.038s

@github-actions github-actions bot added service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. labels Jul 29, 2021
if diff.HasChange("launch_template.0.version") {
_, ok := diff.GetOk("launch_template")

if diff.Id() != "" && diff.HasChange("launch_template.0.version") && ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently HasChange with an empty state will always return true when resource filed has Default value, so I've added a check for top-level key.

@github-actions github-actions bot added size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Aug 2, 2021
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Aug 4, 2021
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

Commercial
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSInstance_LaunchTemplate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSInstance_LaunchTemplate -timeout 180m
=== RUN   TestAccAWSInstance_LaunchTemplate_basic
=== PAUSE TestAccAWSInstance_LaunchTemplate_basic
=== RUN   TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== PAUSE TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== RUN   TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== PAUSE TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== CONT  TestAccAWSInstance_LaunchTemplate_basic
=== CONT  TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== CONT  TestAccAWSInstance_LaunchTemplate_SwapIDAndName
--- PASS: TestAccAWSInstance_LaunchTemplate_basic (65.29s)
--- PASS: TestAccAWSInstance_LaunchTemplate_OverrideTemplate (108.64s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SwapIDAndName (113.77s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SetSpecificVersion (120.50s)
--- PASS: TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion (123.63s)
--- PASS: TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion (219.89s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	223.009s
GovCloud
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSInstance_LaunchTemplate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSInstance_LaunchTemplate -timeout 180m
=== RUN   TestAccAWSInstance_LaunchTemplate_basic
=== PAUSE TestAccAWSInstance_LaunchTemplate_basic
=== RUN   TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== PAUSE TestAccAWSInstance_LaunchTemplate_OverrideTemplate
=== RUN   TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== PAUSE TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== RUN   TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== PAUSE TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== CONT  TestAccAWSInstance_LaunchTemplate_basic
=== CONT  TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_SwapIDAndName
=== CONT  TestAccAWSInstance_LaunchTemplate_SetSpecificVersion
=== CONT  TestAccAWSInstance_LaunchTemplate_OverrideTemplate
--- PASS: TestAccAWSInstance_LaunchTemplate_OverrideTemplate (70.70s)
--- PASS: TestAccAWSInstance_LaunchTemplate_basic (79.14s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SwapIDAndName (125.26s)
--- PASS: TestAccAWSInstance_LaunchTemplate_SetSpecificVersion (134.76s)
--- PASS: TestAccAWSInstance_LaunchTemplate_ModifyTemplate_DefaultVersion (138.20s)
--- PASS: TestAccAWSInstance_LaunchTemplate_UpdateTemplateVersion (190.27s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	193.365s

@ewbankkit
Copy link
Contributor

@gordonbondon Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit d049121 into hashicorp:main Aug 4, 2021
@github-actions github-actions bot added this to the v3.53.0 milestone Aug 4, 2021
@gordonbondon gordonbondon deleted the ec2-launchtemplate-remove-unnecessary-api-calls branch August 4, 2021 18:45
@github-actions
Copy link

github-actions bot commented Aug 5, 2021

This functionality has been released in v3.53.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Sep 5, 2021

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 Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ec2 Issues and PRs that pertain to the ec2 service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
2 participants