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

Add a subnet CIDR reservation resource #22051

Merged
merged 8 commits into from
Dec 8, 2021

Conversation

georgebuckerfield
Copy link
Contributor

This adds a resource - aws_subnet_cidr_reservation - which manages CIDR reservations in subnets.

Unfortunately there is no way to retrieve information about a reservation using it's ID - I can't find any other way to do it than retrieve all reservations for a subnet and then loop through them (the filters suggested in the API docs don't work at all either from what I can tell). I have also not implemented tags - again the API docs seem to be wrong here.

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

Closes #21897

Output from acceptance testing:

make testacc TESTS=TestAccEC2SubnetCidrReservation PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2SubnetCidrReservation' -timeout 180m
=== RUN   TestAccEC2SubnetCidrReservation_basic
=== PAUSE TestAccEC2SubnetCidrReservation_basic
=== RUN   TestAccEC2SubnetCidrReservation_Ipv6
=== PAUSE TestAccEC2SubnetCidrReservation_Ipv6
=== RUN   TestAccEC2SubnetCidrReservation_disappears
=== PAUSE TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_basic
=== CONT  TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_Ipv6
--- PASS: TestAccEC2SubnetCidrReservation_disappears (31.52s)
--- PASS: TestAccEC2SubnetCidrReservation_Ipv6 (36.45s)
--- PASS: TestAccEC2SubnetCidrReservation_basic (36.47s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	39.401s

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 5, 2021
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 @georgebuckerfield 👋

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 CONTRIBUTING 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! 😃

This adds a resource - aws_subnet_cidr_reservation - which manages CIDR reservations in subnets.
@ewbankkit
Copy link
Contributor

@georgebuckerfield Thanks for the contribution.
Everything is looking good so far.
Could you please rename the resource from aws_subnet_cidr_reservation to aws_ec2_subnet_cidr_reservation to conform to our resource naming guildlines.

@t0rr3sp3dr0
Copy link

Is this PR still in draft or is it ready to be reviewed and merged?

@georgebuckerfield georgebuckerfield marked this pull request as ready for review December 7, 2021 06:31
@georgebuckerfield
Copy link
Contributor Author

Is this PR still in draft or is it ready to be reviewed and merged?

I think it's ready for a review now. I haven't added a docs page for it yet - but I should be able to get to that today.

Copy link

@samuel-form3 samuel-form3 left a comment

Choose a reason for hiding this comment

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

lgtm

@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 7, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented Dec 7, 2021

Adding documentation will fix the tfproviderdocs CI failure.

Tests are passing:

% make testacc TESTS=TestAccEC2SubnetCidrReservation_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2SubnetCidrReservation_' -timeout 180m
=== RUN   TestAccEC2SubnetCidrReservation_basic
=== PAUSE TestAccEC2SubnetCidrReservation_basic
=== RUN   TestAccEC2SubnetCidrReservation_Ipv6
=== PAUSE TestAccEC2SubnetCidrReservation_Ipv6
=== RUN   TestAccEC2SubnetCidrReservation_disappears
=== PAUSE TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_basic
=== CONT  TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_Ipv6
--- PASS: TestAccEC2SubnetCidrReservation_disappears (27.47s)
--- PASS: TestAccEC2SubnetCidrReservation_basic (29.55s)
--- PASS: TestAccEC2SubnetCidrReservation_Ipv6 (29.71s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	33.743s

@georgebuckerfield If you can add a documentation page then I can complete the review.
If you don't have time, let us know and we can complete.
Thanks.

@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Dec 7, 2021
@georgebuckerfield
Copy link
Contributor Author

Thanks for the review @ewbankkit - I've just added a doc page, and am working on addressing your other comments.

georgebuckerfield and others added 5 commits December 7, 2021 22:01
Acceptance test output:

% make testacc TESTS=TestAccEC2SubnetCidrReservation_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2SubnetCidrReservation_' -timeout 180m
=== RUN   TestAccEC2SubnetCidrReservation_basic
=== PAUSE TestAccEC2SubnetCidrReservation_basic
=== RUN   TestAccEC2SubnetCidrReservation_ipv6
=== PAUSE TestAccEC2SubnetCidrReservation_ipv6
=== RUN   TestAccEC2SubnetCidrReservation_disappears
=== PAUSE TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_basic
=== CONT  TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_ipv6
--- PASS: TestAccEC2SubnetCidrReservation_disappears (23.80s)
--- PASS: TestAccEC2SubnetCidrReservation_basic (26.04s)
--- PASS: TestAccEC2SubnetCidrReservation_ipv6 (27.04s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	30.710s
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 🚀.

Commercial
% make testacc TESTS=TestAccEC2SubnetCidrReservation_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2SubnetCidrReservation_' -timeout 180m
=== RUN   TestAccEC2SubnetCidrReservation_basic
=== PAUSE TestAccEC2SubnetCidrReservation_basic
=== RUN   TestAccEC2SubnetCidrReservation_ipv6
=== PAUSE TestAccEC2SubnetCidrReservation_ipv6
=== RUN   TestAccEC2SubnetCidrReservation_disappears
=== PAUSE TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_basic
=== CONT  TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_ipv6
--- PASS: TestAccEC2SubnetCidrReservation_disappears (23.80s)
--- PASS: TestAccEC2SubnetCidrReservation_basic (26.04s)
--- PASS: TestAccEC2SubnetCidrReservation_ipv6 (27.04s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	30.710s
GovCloud
% make testacc TESTS=TestAccEC2SubnetCidrReservation_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2SubnetCidrReservation_' -timeout 180m
=== RUN   TestAccEC2SubnetCidrReservation_basic
=== PAUSE TestAccEC2SubnetCidrReservation_basic
=== RUN   TestAccEC2SubnetCidrReservation_ipv6
=== PAUSE TestAccEC2SubnetCidrReservation_ipv6
=== RUN   TestAccEC2SubnetCidrReservation_disappears
=== PAUSE TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_basic
=== CONT  TestAccEC2SubnetCidrReservation_disappears
=== CONT  TestAccEC2SubnetCidrReservation_ipv6
--- PASS: TestAccEC2SubnetCidrReservation_disappears (29.95s)
--- PASS: TestAccEC2SubnetCidrReservation_basic (32.99s)
--- PASS: TestAccEC2SubnetCidrReservation_ipv6 (33.52s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	36.952s

@ewbankkit ewbankkit merged commit 7f026fa into hashicorp:main Dec 8, 2021
@github-actions github-actions bot added this to the v3.69.0 milestone Dec 8, 2021
@github-actions
Copy link

This functionality has been released in v3.69.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 3, 2022

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 3, 2022
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: Implementation of subnet CIDR reservation
5 participants