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

New Data Source: aws_vpc_public_ipv4_pools #28245

Merged

Conversation

theonlymalwhere
Copy link
Contributor

Description

(Note: I originally raised this as Draft PR #28203, but I accidentally broke git on that & so just decided to start over here with the ready-for-review PR).

Presently, there are some gaps in coverage relating to IPv4 Pools. #17425 raises the following user story (among others):

As an IaC engineer, I want to be able to get a list of IPv4 address pools we've added to a specific AWS account via BYOIP so that we can utilise the ranges programatically in the remaining infrastructure.

This gap impacted my org as well (and I have seen several random users on various sites requesting this particular feature), which is why I am submitting this PR, in part-fulfillment of the needs of #17425.

This PR therefore adds the following items:

  1. A new data source (located in the VPC section of the docs, but in the ec2 service directory) called aws_vpc_public_ipv4_pools
  2. Tests and docs for the foregoing data source.

Relations

Relates #17425

Output from Acceptance Testing

n/a (not possible to run because it requires access to public IPv4 addresses). I should note here that all existing tests for BYOIP AND all IPAM variations simply skip any kind of AccTest for public IPv4 addresses, for obvious reasons. There's really nothing I can see in the existing framework to to pattern this approach off of, and I'm struggling to think how we would do this--apart from, e.g., spoofing the existence of public IPv4 pools in the tfstate.

per @ewbankkit (#28203 (comment)):

The HashiCorp maintainers don't have access to BYOIP functionality so in such cases we will:

  1. Make sure that if the changes affect other resources, ensure there are no regressions
  2. Do a code review
  3. Solicit the community for testing
  4. Release the functionality "as-is" (with text in the release notes) and encourage practitioner feedback

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

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 size/XL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 7, 2022
@github-actions github-actions bot removed the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Dec 7, 2022
@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 Dec 8, 2022
@theonlymalwhere theonlymalwhere changed the title Feature: Add aws_vpc_public_ipv4_pools data source New Data SourceL aws_vpc_public_ipv4_pools Dec 11, 2022
@theonlymalwhere theonlymalwhere changed the title New Data SourceL aws_vpc_public_ipv4_pools New Data Source: aws_vpc_public_ipv4_pools Dec 11, 2022
@theonlymalwhere
Copy link
Contributor Author

@ewbankkit Sorry to bother you about this, but I wanted to ask you because you helped out with the original version of this PR (from before I caused an irreconcilable gitastrophe on that PR's branch): It's been a few months since I posted this and I think it just needs some code review from a maintainer to move forward.

Do you know if there's anything I can/should do to request some help with that? My team at work has a pressing need for this data source and I'd love to be able to deliver it! 😅

@theonlymalwhere
Copy link
Contributor Author

(For the record: after this most recent commit ^^, I think I am passing all lint checks again).

Acceptance test output:

% make testacc TESTARGS='-run=TestAccEC2PublicIPv4PoolsDataSource_' PKG=ec2 ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 3  -run=TestAccEC2PublicIPv4PoolsDataSource_ -timeout 180m
=== RUN   TestAccEC2PublicIPv4PoolsDataSource_basic
=== PAUSE TestAccEC2PublicIPv4PoolsDataSource_basic
=== RUN   TestAccEC2PublicIPv4PoolsDataSource_tags
=== PAUSE TestAccEC2PublicIPv4PoolsDataSource_tags
=== CONT  TestAccEC2PublicIPv4PoolsDataSource_basic
=== CONT  TestAccEC2PublicIPv4PoolsDataSource_tags
--- PASS: TestAccEC2PublicIPv4PoolsDataSource_basic (13.84s)
--- PASS: TestAccEC2PublicIPv4PoolsDataSource_tags (13.85s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	19.297s
Acceptance test output:

% make testacc TESTARGS='-run=TestAccEC2PublicIPv4PoolDataSource_' PKG=ec2 ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 3  -run=TestAccEC2PublicIPv4PoolDataSource_ -timeout 180m
=== RUN   TestAccEC2PublicIPv4PoolDataSource_basic
=== PAUSE TestAccEC2PublicIPv4PoolDataSource_basic
=== CONT  TestAccEC2PublicIPv4PoolDataSource_basic
    public_ipv4_pool_data_source_test.go:49: skipping since no EC2 Public IPv4 Pools found
--- SKIP: TestAccEC2PublicIPv4PoolDataSource_basic (0.88s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	7.321s
@ewbankkit ewbankkit added the service/ec2 Issues and PRs that pertain to the ec2 service. label Mar 14, 2023
@github-actions github-actions bot added the generators Relates to code generators. label Mar 14, 2023
@github-actions github-actions bot added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Mar 14, 2023
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 TESTARGS='-run=TestAccEC2PublicIPv4Pool' PKG=ec2 ACCTEST_PARALLELISM=3 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 3  -run=TestAccEC2PublicIPv4Pool -timeout 180m
=== RUN   TestAccEC2PublicIPv4PoolDataSource_basic
=== PAUSE TestAccEC2PublicIPv4PoolDataSource_basic
=== RUN   TestAccEC2PublicIPv4PoolsDataSource_basic
=== PAUSE TestAccEC2PublicIPv4PoolsDataSource_basic
=== RUN   TestAccEC2PublicIPv4PoolsDataSource_tags
=== PAUSE TestAccEC2PublicIPv4PoolsDataSource_tags
=== CONT  TestAccEC2PublicIPv4PoolDataSource_basic
=== CONT  TestAccEC2PublicIPv4PoolsDataSource_tags
=== CONT  TestAccEC2PublicIPv4PoolsDataSource_basic
=== CONT  TestAccEC2PublicIPv4PoolDataSource_basic
    ec2_public_ipv4_pool_data_source_test.go:49: skipping since no EC2 Public IPv4 Pools found
--- SKIP: TestAccEC2PublicIPv4PoolDataSource_basic (0.84s)
--- PASS: TestAccEC2PublicIPv4PoolsDataSource_basic (12.61s)
--- PASS: TestAccEC2PublicIPv4PoolsDataSource_tags (12.62s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	17.951s

@ewbankkit
Copy link
Contributor

@gatsbysghost Thanks for the contribution 🎉 👏.
I renamed the data sources to aws_ec2_public_ipv4_pool and aws_ec2_public_ipv4_pools as the underlying AWS API used is listed in the Amazon EC2 actions section of the documentation.
I also modified the attributes returned to better match our pattern of the plural data source returning just a list of IDs and the singular data source accepting a single ID and returning all the attributes for the specified resource.

@github-actions github-actions bot added github_actions Pull requests that update Github_actions code repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. labels Mar 14, 2023
@theonlymalwhere
Copy link
Contributor Author

@ewbankkit Fab! Thank you so much for your help! 😁

@ewbankkit ewbankkit merged commit 4ffa2b0 into hashicorp:main Mar 14, 2023
@github-actions github-actions bot added this to the v4.59.0 milestone Mar 14, 2023
@github-actions
Copy link

This functionality has been released in v4.59.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

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 Apr 16, 2023
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. generators Relates to code generators. github_actions Pull requests that update Github_actions code new-data-source Introduces a new data source. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. 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