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: New resource #6291

Merged
merged 6 commits into from
Oct 31, 2018

Conversation

gazoakley
Copy link
Contributor

@gazoakley gazoakley commented Oct 28, 2018

Fixes #6289

Changes proposed in this pull request:

  • New aws_ec2_capacity_reservation resource

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSEc2CapacityReservation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSEc2CapacityReservation -timeout 120m
=== RUN   TestAccAWSEc2CapacityReservation_importBasic
=== PAUSE TestAccAWSEc2CapacityReservation_importBasic
=== RUN   TestAccAWSEc2CapacityReservation_basic
=== PAUSE TestAccAWSEc2CapacityReservation_basic
=== RUN   TestAccAWSEc2CapacityReservation_endDate
=== PAUSE TestAccAWSEc2CapacityReservation_endDate
=== RUN   TestAccAWSEc2CapacityReservation_tags
=== PAUSE TestAccAWSEc2CapacityReservation_tags
=== CONT  TestAccAWSEc2CapacityReservation_importBasic
=== CONT  TestAccAWSEc2CapacityReservation_tags
=== CONT  TestAccAWSEc2CapacityReservation_endDate
=== CONT  TestAccAWSEc2CapacityReservation_basic
--- PASS: TestAccAWSEc2CapacityReservation_endDate (148.23s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (154.76s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (159.46s)
--- PASS: TestAccAWSEc2CapacityReservation_importBasic (204.96s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	205.008s

@ghost ghost added size/XL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 28, 2018
aws/provider.go Outdated Show resolved Hide resolved
@gazoakley gazoakley changed the title [WIP] resource/aws_capacity_reservation: New resource [WIP] resource/aws_ec2_capacity_reservation: New resource Oct 30, 2018
@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Oct 30, 2018
@bflad bflad added the new-resource Introduces a new resource. label Oct 30, 2018
@gazoakley gazoakley changed the title [WIP] resource/aws_ec2_capacity_reservation: New resource resource/aws_ec2_capacity_reservation: New resource Oct 31, 2018
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.

Thanks for submitting this @gazoakley! Its off to a great start -- left some comments below and we should be able to get this in afterwards. Please let us know if you have any questions or do not have time to implement these items. Thanks!

aws/resource_aws_ec2_capacity_reservation.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation.go Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation.go Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation_test.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation_test.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation_test.go Outdated Show resolved Hide resolved
aws/resource_aws_ec2_capacity_reservation_test.go Outdated Show resolved Hide resolved

* `availability_zone` - (Required) The Availability Zone in which to create the Capacity Reservation.
* `ebs_optimized` - (Optional) Indicates whether the Capacity Reservation supports EBS-optimized instances.
* `end_date` - (Optional) The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably include a note about it being in RFC3339 format as well.

Suggested change
* `end_date` - (Optional) The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it.
* `end_date` - (Optional) The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. Valid values: [RFC3339 time string](https://tools.ietf.org/html/rfc3339#section-5.8) (`YYYY-MM-DDTHH:MM:SSZ`)

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Oct 31, 2018
@gazoakley
Copy link
Contributor Author

Thanks @bflad - I'll take a look later 👍

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Oct 31, 2018
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.

Thanks so much for all your work here, @gazoakley! This was really really close. 😄

I found these after running the acceptance testing:

--- FAIL: TestAccAWSEc2CapacityReservation_tags (10.12s)
    testing.go:538: Step 0 error: Check failed: Check 2/3 error: aws_ec2_capacity_reservation.default: Attribute 'tags.%' expected "1", got "0"
--- FAIL: TestAccAWSEc2CapacityReservation_endDate (14.53s)
    testing.go:538: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) {
        }


        (map[string]string) (len=1) {
         (string) (len=8) "end_date": (string) (len=20) "2019-10-31T07:39:57Z"
        }

--- PASS: TestAccAWSEc2CapacityReservation_basic (14.56s)

They just required some minor adjustments in the resource. I also augmented the acceptance testing to cover all the attributes along with updates so we could release this today. I hope you don't mind. 😅

--- SKIP: TestAccAWSEc2CapacityReservation_tenancy (0.00s)
    resource_aws_ec2_capacity_reservation_test.go:357: EC2 Capacity Reservations do not currently support dedicated tenancy.
--- PASS: TestAccAWSEc2CapacityReservation_ephemeralStorage (15.02s)
--- PASS: TestAccAWSEc2CapacityReservation_ebsOptimized (15.04s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceMatchCriteria (15.28s)
--- PASS: TestAccAWSEc2CapacityReservation_basic (15.30s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceCount (24.59s)
--- PASS: TestAccAWSEc2CapacityReservation_endDate (24.78s)
--- PASS: TestAccAWSEc2CapacityReservation_instanceType (25.39s)
--- PASS: TestAccAWSEc2CapacityReservation_endDateType (33.18s)
--- PASS: TestAccAWSEc2CapacityReservation_tags (35.14s)

@bflad bflad added this to the v1.42.0 milestone Oct 31, 2018
@bflad bflad merged commit 6b53580 into hashicorp:master Oct 31, 2018
bflad added a commit that referenced this pull request Oct 31, 2018
@bflad
Copy link
Contributor

bflad commented Nov 1, 2018

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

@GeorgiSK
Copy link

Hey, how can a capacity reservation be targeted when creating aws_intance resource? Was this added as part of this enhancement, because I am unable to find it? Thanks.

@skashmeri
Copy link

Hey, how can a capacity reservation be targeted when creating aws_intance resource? Was this added as part of this enhancement, because I am unable to find it? Thanks.

Just came upon this, Im creating a capacity reservation and ec2 in terraform and need to target the capacity reservation for the instance, is this possibe? terraform 0.11.14

@ghost
Copy link

ghost commented Nov 2, 2019

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 and limited conversation to collaborators Nov 2, 2019
@gazoakley gazoakley deleted the f-capacity-reservation branch April 7, 2020 16:18
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-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. 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.

Feature Request: Support for EC2 Capacity Reservations
4 participants