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

Added resource and data source for aws ec2 capacity block reservation. #37528

Merged

Conversation

prabhavpawar
Copy link
Contributor

@prabhavpawar prabhavpawar commented May 15, 2024

Description
This PR adds a resource for aws_ec2_capacity_block_reservation and data-source for aws_ec2_capacity_block_offering. With Capacity Blocks, GPU instance capacity is available on future dates, and a Capacity Block can be scheduled to start at a time.

Relations
Closes #35358

References
Capacity Block Docs

Output from Acceptance Testing

TF_ACC=1 /opt/devshell/go/latest/bin/go test  internal/service/ec2/ec2_capacity_block_offering_data_source_test.go -v  -count 1 -parallel 1 -run=TestAccEC2CapacityBlockOffering_basic
=== RUN   TestAccEC2CapacityBlockOffering_basic
=== PAUSE TestAccEC2CapacityBlockOffering_basic
=== CONT  TestAccEC2CapacityBlockOffering_basic
--- PASS: TestAccEC2CapacityBlockOffering_basic (27.46s)
PASS
ok  command-line-arguments  29.812s

TF_ACC=1 /opt/devshell/go/latest/bin/go test  internal/service/ec2/ec2_capacity_block_reservation_test.go -v  -count 1 -parallel 1 -run=TestAccEC2CapacityBlockReservation_basic
=== RUN   TestAccEC2CapacityBlockReservation_basic
=== PAUSE TestAccEC2CapacityBlockReservation_basic
=== CONT  TestAccEC2CapacityBlockReservation_basic
    ec2_capacity_block_reservation_test.go:37: Step 1/1 error: Error running apply: exit status 1
        Error: creating EC2 Capacity Reservation: UnauthorizedOperation: You are not authorized to perform this operation. User: arn:aws:sts::878176493429:assumed-role/90467-application-engineer/O664318@ASIAPAC.AD.JPMORGANCHASE.com is not authorized to perform: ec2:PurchaseCapacityBlock on resource: arn:aws:ec2:us-west-2:878176493429:capacity-reservation/* because no identity-based policy allows the ec2:PurchaseCapacityBlock action. Encoded authorization failure message: ...
        	status code: 403, request id: 99a38e9a-cb56-4ec4-9dc8-b33eb5a4026e
          with aws_ec2_capacity_block_reservation.test,
          on terraform_plugin_test.tf line 20, in resource "aws_ec2_capacity_block_reservation" "test":
          20: resource "aws_ec2_capacity_block_reservation" "test" {
--- FAIL: TestAccEC2CapacityBlockReservation_basic (18.76s)
FAIL
FAIL	command-line-arguments	21.122s
FAIL

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. labels May 15, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 15, 2024
@github-actions github-actions bot added the size/XL Managed by automation to categorize the size of a PR. label May 15, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @prabhavpawar 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels May 16, 2024
@johnsonaj johnsonaj self-assigned this Jun 3, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jun 3, 2024
@prabhavpawar
Copy link
Contributor Author

Thanks Johnson for fixing the issues. Appreciate the help!
What's pending the merge the changes?

@johnsonaj
Copy link
Contributor

% make testacc TESTARGS='-run=TestAccEC2CapacityBlockOfferingDataSource_' PKG=ec2

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2CapacityBlockOfferingDataSource_ -timeout 360m
=== RUN   TestAccEC2CapacityBlockOfferingDataSource_basic
=== PAUSE TestAccEC2CapacityBlockOfferingDataSource_basic
=== CONT  TestAccEC2CapacityBlockOfferingDataSource_basic
--- PASS: TestAccEC2CapacityBlockOfferingDataSource_basic (8.86s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	14.540s

@johnsonaj johnsonaj added the new-data-source Introduces a new data source. label Jun 11, 2024
Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@johnsonaj
Copy link
Contributor

@prabhavpawar thank you for the contribution! 🎉

@johnsonaj johnsonaj merged commit 6e42aab into hashicorp:main Jun 11, 2024
44 checks passed
@github-actions github-actions bot added this to the v5.54.0 milestone Jun 11, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jun 14, 2024
Copy link

This functionality has been released in v5.54.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!

Copy link

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 Jul 15, 2024
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. new-data-source Introduces a new data source. new-resource Introduces a new resource. 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.

[New Resource]: Add Capacity Block for AWS EC2 Capacity Reservation
3 participants