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 and r/d/aws_launch_template - cpu options #31035

Merged
merged 27 commits into from
Apr 28, 2023

Conversation

GlennChia
Copy link
Collaborator

@GlennChia GlennChia commented Apr 28, 2023

Description

Feature documentation: CPU features

This PR adds support for amd_sev_snp argument. This is part of the cpu_options argument.

As part of this PR the following changes are done

  1. aws_instance resource: Deprecate cpu_core_count in favor of cpu_options.0.core_count
  2. aws_instance resource: Deprecate cpu_threads_per_core in favor of cpu_options.0.threads_per_core
  3. aws_instance resource: Introduce cpu_options.0.amd_sev_snp
  4. aws_launch_template resource: Introduce cpu_options.0.amd_sev_snp
  5. aws_launch_template data source: Introduce cpu_options.0.amd_sev_snp

NOTE: From the Requirements doc, as of this writing, only certain regions are supported. Hence, testing of amd_sev_snp is done in us-east-2

Test cases introduced

aws_instance resource

  1. cpu_options: Create, update of core_count and threads_per_core
  2. cpu_options: Migration from deprecated args cpu_core_count and cpu_threads_per_core to cpu_options.0.core_count and cpu_options.0.threads_per_core
  3. cpu_options: EC2 instance is not recreated when users transition from not specifying any cpu_options to specifying the default cpu_options
  4. cpu_options: Create, update amd_sev_snp
    • From created disabled to updated enabled
    • From created enabled to updateddisabled
  5. cpu_options: Create, update of amd_sev_snp with core_count and threads_per_core
  6. cpu_options: Migration from EC2 instance that does not have cpu_options to EC2 instance that has amd_sev_snp set as disabled. Expect no recreation. Note that since the READ function is not called, the value of amd_sev_snp is not changed in state and will still be an empty string. From testing, the API will not return amd_sev_snp if it is not set as either disabled or enabled at launch time
  7. cpu_options: Migration from EC2 instance that has cpu_options with amd_sev_snp to EC2 instance without cpu_options. Expect no recreation

aws_launch_template resource

  1. cpu_options: Create, update amd_sev_snp

aws_launch_template data source

  1. cpu_options: Read amd_sev_snp

Relations

Closes #31036
Depends on #31028

References

Output from Acceptance Testing

aws_instance resource

You might encounter issues with the instance type and AZ used in the test cases. Change the AZ used in the tests accordingly to fix these errors.

$ make testacc TESTARGS='-run=TestAccEC2Instance_cpuOptions\|TestInstanceCPU' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2Instance_cpuOptions\|TestInstanceCPU -timeout 180m
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreads
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreads
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== RUN   TestInstanceCPUCoreCountSchema
=== PAUSE TestInstanceCPUCoreCountSchema
=== RUN   TestInstanceCPUThreadsPerCoreSchema
=== PAUSE TestInstanceCPUThreadsPerCoreSchema
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreads
=== CONT  TestInstanceCPUCoreCountSchema
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== CONT  TestInstanceCPUThreadsPerCoreSchema
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
--- PASS: TestInstanceCPUCoreCountSchema (0.00s)
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
--- PASS: TestInstanceCPUThreadsPerCoreSchema (0.00s)
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreadsMigration (108.62s)
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified (119.83s)
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreads (206.07s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads (207.26s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled (217.56s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified (233.48s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled (432.28s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified (564.83s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        567.254s
...

aws_launch_template resource

$ make testacc TESTARGS='-run=TestAccEC2LaunchTemplate_cpuOptions' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2LaunchTemplate_cpuOptions -timeout 180m
=== RUN   TestAccEC2LaunchTemplate_cpuOptions
=== PAUSE TestAccEC2LaunchTemplate_cpuOptions
=== CONT  TestAccEC2LaunchTemplate_cpuOptions
--- PASS: TestAccEC2LaunchTemplate_cpuOptions (38.09s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        38.201s

aws_launch_template data source

$ make testacc TESTARGS='-run=TestAccEC2LaunchTemplateDataSource_name' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2LaunchTemplateDataSource_name -timeout 180m
=== RUN   TestAccEC2LaunchTemplateDataSource_name
=== PAUSE TestAccEC2LaunchTemplateDataSource_name
=== CONT  TestAccEC2LaunchTemplateDataSource_name
--- PASS: TestAccEC2LaunchTemplateDataSource_name (27.05s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        27.161s

@github-actions
Copy link

Community Note

Voting for Prioritization

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

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. partner Contribution from a partner. needs-triage Waiting for first response or review from a maintainer. labels Apr 28, 2023
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Apr 28, 2023
@jar-b jar-b self-assigned this Apr 28, 2023
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

$ make testacc TESTARGS='-run=TestAccEC2LaunchTemplate_cpuOptions' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2LaunchTemplate_cpuOptions -timeout 180m
=== RUN   TestAccEC2LaunchTemplate_cpuOptions
=== PAUSE TestAccEC2LaunchTemplate_cpuOptions
=== CONT  TestAccEC2LaunchTemplate_cpuOptions
--- PASS: TestAccEC2LaunchTemplate_cpuOptions (14.92s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        18.150s
$ make testacc TESTARGS='-run=TestAccEC2Instance_cpuOptions\|TestInstanceCPU' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2Instance_cpuOptions\|TestInstanceCPU -timeout 180m
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
=== RUN   TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== PAUSE TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreads
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreads
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== RUN   TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== PAUSE TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== RUN   TestInstanceCPUCoreCountSchema
=== PAUSE TestInstanceCPUCoreCountSchema
=== RUN   TestInstanceCPUThreadsPerCoreSchema
=== PAUSE TestInstanceCPUThreadsPerCoreSchema
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreads
=== CONT  TestInstanceCPUCoreCountSchema
=== CONT  TestInstanceCPUThreadsPerCoreSchema
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified
=== CONT  TestAccEC2Instance_cpuOptionsCoreThreadsMigration
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads
=== CONT  TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled
--- PASS: TestInstanceCPUCoreCountSchema (0.00s)
--- PASS: TestInstanceCPUThreadsPerCoreSchema (0.00s)
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreadsMigration (87.23s)
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreadsUnspecifiedToSpecified (117.56s)
--- PASS: TestAccEC2Instance_cpuOptionsCoreThreads (120.22s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToDisabledToEnabledToUnspecified (368.04s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpEnabledToDisabled (392.68s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpDisabledToEnabled (402.45s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpCoreThreads (412.69s)
--- PASS: TestAccEC2Instance_cpuOptionsAmdSevSnpUnspecifiedToEnabledToDisabledToUnspecified (461.69s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        465.158s

@jar-b jar-b merged commit 19d172d into hashicorp:main Apr 28, 2023
@jar-b
Copy link
Member

jar-b commented Apr 28, 2023

Thanks for your contribution, @GlennChia! 👏

@github-actions github-actions bot added this to the v4.66.0 milestone Apr 28, 2023
@GlennChia GlennChia deleted the f-aws_instance-cpu_options branch April 30, 2023 14:33
@GlennChia
Copy link
Collaborator Author

Thanks @jar-b! I forgot to add the results from the tests for the aws_launch_template data source. Edited the main PR description and also pasting the test results below:

$ make testacc TESTARGS='-run=TestAccEC2LaunchTemplateDataSource_name' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2LaunchTemplateDataSource_name -timeout 180m
=== RUN   TestAccEC2LaunchTemplateDataSource_name
=== PAUSE TestAccEC2LaunchTemplateDataSource_name
=== CONT  TestAccEC2LaunchTemplateDataSource_name
--- PASS: TestAccEC2LaunchTemplateDataSource_name (27.05s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        27.161s

@github-actions
Copy link

github-actions bot commented May 5, 2023

This functionality has been released in v4.66.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 Jun 6, 2023

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 Jun 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. partner Contribution from a partner. service/ec2 Issues and PRs that pertain to the ec2 service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: aws_instance and aws_launch_template add/update cpu_options
3 participants