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: add aws_instance_types_from_instance_requirements data source #34030

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

iandrewt
Copy link
Contributor

Description

This adds the GetInstanceTypesFromInstanceRequirements API used by Autoscaling and Spot Fleet as a generic data source. I'm planning to use this for the instance_types attribute in an aws_eks_node_group resource so I can filter instance types better than with the aws_ec2_instance_types data source

References

GetInstanceTypesFromInstanceRequirements documentation

Output from Acceptance Testing

% make testacc TESTARGS='-run=TestAccEC2InstanceTypesFromInstanceRequirementsDataSource' PKG=ec2 ACCTEST_PARALLELISM=8
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 8  -run=TestAccEC2InstanceTypesFromInstanceRequirementsDataSource -timeout 360m
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryMiBAndVcpuCount
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryMiBAndVcpuCount
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorCount
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorCount
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorManufacturers
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorManufacturers
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorNames
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorNames
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTotalMemoryMiB
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTotalMemoryMiB
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTypes
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTypes
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_allowedInstanceTypes
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_allowedInstanceTypes
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_bareMetal
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_bareMetal
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_baselineEbsBandwidthMbps
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_baselineEbsBandwidthMbps
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_burstablePerformance
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_burstablePerformance
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_cpuManufacturers
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_cpuManufacturers
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_excludedInstanceTypes
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_excludedInstanceTypes
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_instanceGenerations
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_instanceGenerations
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorage
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorage
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorageTypes
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorageTypes
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryGiBPerVCpu
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryGiBPerVCpu
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkBandwidthGbps
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkBandwidthGbps
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkInterfaceCount
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkInterfaceCount
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_onDemandMaxPricePercentageOverLowestPrice
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_onDemandMaxPricePercentageOverLowestPrice
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_requireHibernateSupport
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_requireHibernateSupport
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_spotMaxPricePercentageOverLowestPrice
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_spotMaxPricePercentageOverLowestPrice
=== RUN   TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_totalLocalStorageGB
=== PAUSE TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_totalLocalStorageGB
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryMiBAndVcpuCount
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_excludedInstanceTypes
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkInterfaceCount
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_allowedInstanceTypes
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorNames
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTypes
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTotalMemoryMiB
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorManufacturers
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorNames (50.33s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_spotMaxPricePercentageOverLowestPrice
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_excludedInstanceTypes (53.29s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_totalLocalStorageGB
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_allowedInstanceTypes (54.44s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorCount
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryMiBAndVcpuCount (54.45s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_burstablePerformance
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTypes (54.61s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_cpuManufacturers
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorManufacturers (54.65s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorageTypes
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkInterfaceCount (75.52s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkBandwidthGbps
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorTotalMemoryMiB (77.01s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryGiBPerVCpu
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_spotMaxPricePercentageOverLowestPrice (26.84s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_requireHibernateSupport
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorageTypes (49.26s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_onDemandMaxPricePercentageOverLowestPrice
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_cpuManufacturers (49.35s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorage
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_totalLocalStorageGB (67.12s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_instanceGenerations
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_acceleratorCount (67.51s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_baselineEbsBandwidthMbps
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_requireHibernateSupport (47.84s)
=== CONT  TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_bareMetal
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_burstablePerformance (71.18s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_onDemandMaxPricePercentageOverLowestPrice (25.60s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_networkBandwidthGbps (66.06s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_memoryGiBPerVCpu (65.28s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_instanceGenerations (39.81s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_localStorage (61.51s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_baselineEbsBandwidthMbps (56.97s)
--- PASS: TestAccEC2InstanceTypesFromInstanceRequirementsDataSource_bareMetal (55.74s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        183.171s
...

@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. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/ec2 Issues and PRs that pertain to the ec2 service. generators Relates to code generators. size/XL Managed by automation to categorize the size of a PR. labels Oct 20, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 20, 2023
@justinretzolk justinretzolk added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 23, 2023
@iandrewt
Copy link
Contributor Author

Happy to rewrite this one in aws-sdk-go-v2 as per #32976 if desired

@pascal-hofmann
Copy link
Contributor

Hi everyone,
what's the status on this? It would be great to have this data source available soon.

Cheers
Pascal

@iandrewt
Copy link
Contributor Author

Hi everyone,

what's the status on this? It would be great to have this data source available soon.

Cheers

Pascal

I ended up switching to Karpenter so I no longer have a requirement to create node groups with specific instance requirements, but I'm happy to sit down and do the sdk-v2 refactor if this data source is still desired

@pascal-hofmann
Copy link
Contributor

I think this would be a great addition. Maybe the maintainers can also post their view on this?

CC @johnsonaj

@iandrewt
Copy link
Contributor Author

iandrewt commented May 6, 2024

Refactored to AWS SDK Go V2. Passes all the same tests as before. Now uses the AutoExpand flex functions which tidies up the code quite a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-data-source Introduces a new data source. 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.

3 participants