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

resource/aws_ec2_capacity_reservation: Fix to set ARN from its response and add owner_id attribute #17129

Merged
merged 3 commits into from
Feb 11, 2021

Conversation

shuheiktgw
Copy link
Collaborator

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

Relates #16978

Release note for CHANGELOG:

* resource/aws_ec2_capacity_reservation: Add owner_id attribute

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSEc2CapacityReservation_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSEc2CapacityReservation_* -timeout 120m
=== RUN   TestAccAWSEc2CapacityReservation_basic
=== PAUSE TestAccAWSEc2CapacityReservation_basic
=== RUN   TestAccAWSEc2CapacityReservation_ebsOptimized
=== PAUSE TestAccAWSEc2CapacityReservation_ebsOptimized
=== RUN   TestAccAWSEc2CapacityReservation_endDate
=== PAUSE TestAccAWSEc2CapacityReservation_endDate
=== RUN   TestAccAWSEc2CapacityReservation_endDateType
=== PAUSE TestAccAWSEc2CapacityReservation_endDateType
=== RUN   TestAccAWSEc2CapacityReservation_ephemeralStorage
=== PAUSE TestAccAWSEc2CapacityReservation_ephemeralStorage
=== RUN   TestAccAWSEc2CapacityReservation_instanceCount
=== PAUSE TestAccAWSEc2CapacityReservation_instanceCount
=== RUN   TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== PAUSE TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== RUN   TestAccAWSEc2CapacityReservation_instanceType
=== PAUSE TestAccAWSEc2CapacityReservation_instanceType
=== RUN   TestAccAWSEc2CapacityReservation_tags
=== PAUSE TestAccAWSEc2CapacityReservation_tags
=== RUN   TestAccAWSEc2CapacityReservation_disappears
=== PAUSE TestAccAWSEc2CapacityReservation_disappears
=== RUN   TestAccAWSEc2CapacityReservation_tenancy
    provider_test.go:56: EC2 Capacity Reservations do not currently support dedicated tenancy.
--- SKIP: TestAccAWSEc2CapacityReservation_tenancy (0.00s)
=== CONT  TestAccAWSEc2CapacityReservation_basic
=== CONT  TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== CONT  TestAccAWSEc2CapacityReservation_disappears
=== CONT  TestAccAWSEc2CapacityReservation_instanceType
=== CONT  TestAccAWSEc2CapacityReservation_endDateType
=== CONT  TestAccAWSEc2CapacityReservation_instanceCount
=== CONT  TestAccAWSEc2CapacityReservation_tags
=== CONT  TestAccAWSEc2CapacityReservation_ephemeralStorage
=== CONT  TestAccAWSEc2CapacityReservation_endDate
=== CONT  TestAccAWSEc2CapacityReservation_ebsOptimized
--- PASS: TestAccAWSEc2CapacityReservation_disappears (50.26s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (54.86s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (59.14s)
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (59.20s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (59.57s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (81.62s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (84.38s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (84.71s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (104.90s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (107.50s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	109.433s

Thank you for your review! 👍

@shuheiktgw shuheiktgw requested a review from a team as a code owner January 15, 2021 11:00
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. 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. labels Jan 15, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 15, 2021
@@ -88,6 +88,7 @@ func TestAccAWSEc2CapacityReservation_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "instance_match_criteria", "open"),
resource.TestCheckResourceAttr(resourceName, "instance_platform", "Linux/UNIX"),
resource.TestCheckResourceAttr(resourceName, "instance_type", "t2.micro"),
resource.TestCheckResourceAttrSet(resourceName, "owner_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can verify that the owner_id is set to the current AWS account ID.

Suggested change
resource.TestCheckResourceAttrSet(resourceName, "owner_id"),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't know that kind of test helper exists. Thank you!

@shuheiktgw
Copy link
Collaborator Author

make testacc TESTARGS='-run=TestAccAWSEc2CapacityReservation_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSEc2CapacityReservation_* -timeout 120m
=== RUN   TestAccAWSEc2CapacityReservation_basic
=== PAUSE TestAccAWSEc2CapacityReservation_basic
=== RUN   TestAccAWSEc2CapacityReservation_ebsOptimized
=== PAUSE TestAccAWSEc2CapacityReservation_ebsOptimized
=== RUN   TestAccAWSEc2CapacityReservation_endDate
=== PAUSE TestAccAWSEc2CapacityReservation_endDate
=== RUN   TestAccAWSEc2CapacityReservation_endDateType
=== PAUSE TestAccAWSEc2CapacityReservation_endDateType
=== RUN   TestAccAWSEc2CapacityReservation_ephemeralStorage
=== PAUSE TestAccAWSEc2CapacityReservation_ephemeralStorage
=== RUN   TestAccAWSEc2CapacityReservation_instanceCount
=== PAUSE TestAccAWSEc2CapacityReservation_instanceCount
=== RUN   TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== PAUSE TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== RUN   TestAccAWSEc2CapacityReservation_instanceType
=== PAUSE TestAccAWSEc2CapacityReservation_instanceType
=== RUN   TestAccAWSEc2CapacityReservation_tags
=== PAUSE TestAccAWSEc2CapacityReservation_tags
=== RUN   TestAccAWSEc2CapacityReservation_disappears
=== PAUSE TestAccAWSEc2CapacityReservation_disappears
=== RUN   TestAccAWSEc2CapacityReservation_tenancy
    provider_test.go:56: EC2 Capacity Reservations do not currently support dedicated tenancy.
--- SKIP: TestAccAWSEc2CapacityReservation_tenancy (0.00s)
=== CONT  TestAccAWSEc2CapacityReservation_basic
=== CONT  TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== CONT  TestAccAWSEc2CapacityReservation_tags
=== CONT  TestAccAWSEc2CapacityReservation_instanceType
=== CONT  TestAccAWSEc2CapacityReservation_endDateType
=== CONT  TestAccAWSEc2CapacityReservation_instanceCount
=== CONT  TestAccAWSEc2CapacityReservation_ephemeralStorage
=== CONT  TestAccAWSEc2CapacityReservation_endDate
=== CONT  TestAccAWSEc2CapacityReservation_disappears
=== CONT  TestAccAWSEc2CapacityReservation_ebsOptimized
--- PASS: TestAccAWSEc2CapacityReservation_disappears (55.56s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (63.25s)
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (64.15s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (65.51s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (65.75s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (94.27s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (96.28s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (106.68s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (118.39s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (120.74s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	122.683s

@shuheiktgw
Copy link
Collaborator Author

@ewbankkit Fixed it so would you review the PR again? 🙏

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.

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSEc2CapacityReservation_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSEc2CapacityReservation_ -timeout 120m
=== RUN   TestAccAWSEc2CapacityReservation_basic
=== PAUSE TestAccAWSEc2CapacityReservation_basic
=== RUN   TestAccAWSEc2CapacityReservation_ebsOptimized
=== PAUSE TestAccAWSEc2CapacityReservation_ebsOptimized
=== RUN   TestAccAWSEc2CapacityReservation_endDate
=== PAUSE TestAccAWSEc2CapacityReservation_endDate
=== RUN   TestAccAWSEc2CapacityReservation_endDateType
=== PAUSE TestAccAWSEc2CapacityReservation_endDateType
=== RUN   TestAccAWSEc2CapacityReservation_ephemeralStorage
=== PAUSE TestAccAWSEc2CapacityReservation_ephemeralStorage
=== RUN   TestAccAWSEc2CapacityReservation_instanceCount
=== PAUSE TestAccAWSEc2CapacityReservation_instanceCount
=== RUN   TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== PAUSE TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== RUN   TestAccAWSEc2CapacityReservation_instanceType
=== PAUSE TestAccAWSEc2CapacityReservation_instanceType
=== RUN   TestAccAWSEc2CapacityReservation_tags
=== PAUSE TestAccAWSEc2CapacityReservation_tags
=== RUN   TestAccAWSEc2CapacityReservation_disappears
=== PAUSE TestAccAWSEc2CapacityReservation_disappears
=== RUN   TestAccAWSEc2CapacityReservation_tenancy
    provider_test.go:56: EC2 Capacity Reservations do not currently support dedicated tenancy.
--- SKIP: TestAccAWSEc2CapacityReservation_tenancy (0.00s)
=== CONT  TestAccAWSEc2CapacityReservation_basic
=== CONT  TestAccAWSEc2CapacityReservation_disappears
=== CONT  TestAccAWSEc2CapacityReservation_tags
=== CONT  TestAccAWSEc2CapacityReservation_instanceType
=== CONT  TestAccAWSEc2CapacityReservation_instanceMatchCriteria
=== CONT  TestAccAWSEc2CapacityReservation_instanceCount
=== CONT  TestAccAWSEc2CapacityReservation_ephemeralStorage
=== CONT  TestAccAWSEc2CapacityReservation_endDateType
=== CONT  TestAccAWSEc2CapacityReservation_endDate
=== CONT  TestAccAWSEc2CapacityReservation_ebsOptimized
--- PASS: TestAccAWSEc2CapacityReservation_disappears (32.18s)
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (37.22s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (37.94s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (38.23s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (38.24s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (51.76s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (51.93s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (52.87s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (64.23s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (64.51s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	64.607s

Base automatically changed from master to main January 23, 2021 01:00
@bflad bflad self-assigned this Feb 11, 2021
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Feb 11, 2021
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Super happy to see these in the API. Thank you, @shuheiktgw 🚀

Output from acceptance testing in AWS Commercial:

--- PASS: TestAccAWSEc2CapacityReservation_disappears (21.93s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (25.87s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (25.99s)
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (26.00s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (26.39s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (37.97s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (38.20s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (38.55s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (48.65s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (49.90s)

Output from acceptance testing in AWS GovCloud (US):

--- PASS: TestAccAWSEc2CapacityReservation_disappears (25.87s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (28.03s)
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (28.90s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (29.25s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (29.76s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (42.88s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (44.02s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (44.05s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (57.51s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (58.11s)

Comment on lines -215 to -221
arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "ec2",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("capacity-reservation/%s", d.Id()),
}.String()
Copy link
Contributor

Choose a reason for hiding this comment

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

When removing this type of manual ARN building, we should double check that it is not in the website/docs/index.html file skip_requesting_account_id list of resources that are documented as potentially not working. 👍

bflad added a commit that referenced this pull request Feb 11, 2021
@bflad bflad merged commit 29e16ed into hashicorp:main Feb 11, 2021
@github-actions github-actions bot added this to the v3.28.0 milestone Feb 11, 2021
bflad added a commit that referenced this pull request Feb 11, 2021
@ghost
Copy link

ghost commented Feb 12, 2021

This has been released in version 3.28.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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 14, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 14, 2021
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. enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS 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