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

Draft: Add Public IPv4 Pools data source #28203

Conversation

theonlymalwhere
Copy link
Contributor

@theonlymalwhere theonlymalwhere commented Dec 6, 2022

Description

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.

A substantial question in my mind when I was writing this code was: does it go too far for a data source? Most data sources that can read & provide data on a range of resources only include, as output:

  • The IDs of those resources
  • An ID for the data source itself (generally, just a meta call back to the region).

This is obviously going a step further in providing structured output according to the DescribePublicIpv4Pools API method. I would appreciate any feedback on whether or not that is, categorically, too much output to include in a Data Source. But on the other hand, users (including myself) have need of a method that simply takes one or more IPv4 pool IDs and returns information about those pools. This is how I chose to implement that, but I am open to requests for changes.

A further question I have for reviewers would be: Have I correctly inferred the error type for my Finder in internal/service/ec2/find.go:1234? I could not find much in the way of documentation about writing Finders in general.

Finally: I am working on acceptance testing, and this has Draft status until I get tests passing. However, due to the nature of this particular resource, it is quite difficult to run Acceptance Tests; we would need to be able to provision a BYOIP pool of public IPs (and this is kinda cost-prohibitive, as well as requiring a manual step to sign and attach a CIDR Authorization Context to the IPAM pool in order to create an IPAM pool CIDR. Any input on how to test this in the existing framework...I am open to your thoughts.

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.

Relations

Relates #17425

Output from Acceptance Testing

$ make testacc TESTS=TestAccVPCPublicIpv4PoolsDataSource PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCPublicIpv4PoolsDataSource'  -timeout 180m
=== RUN   TestAccVPCPublicIpv4PoolsDataSource_filter
    public_ipv4_pools_data_source_test.go:16: Step 1/1 error: Error running apply: exit status 1

        Error: creating IPAM Pool (ipam-pool-0bce7e0554f54c98c) CIDR: InvalidParameterCombination: The request must contain a CIDR Authorization Context for ipam-pool-0bce7e0554f54c98c. The specified pool belongs to a public scope where the specified CIDR has not previously been provisioned.
        	status code: 400, request id: 8805a3a8-9ed2-4ef6-a9df-ed6ffff12639

          with aws_vpc_ipam_pool_cidr.test_cidr_1,
          on terraform_plugin_test.tf line 29, in resource "aws_vpc_ipam_pool_cidr" "test_cidr_1":
          29: resource "aws_vpc_ipam_pool_cidr" "test_cidr_1" {


        Error: creating IPAM Pool (ipam-pool-0bce7e0554f54c98c) CIDR: InvalidParameterCombination: The request must contain a CIDR Authorization Context for ipam-pool-0bce7e0554f54c98c. The specified pool belongs to a public scope where the specified CIDR has not previously been provisioned.
        	status code: 400, request id: bf9f7023-9429-484a-a26d-f0630f4ef76e

          with aws_vpc_ipam_pool_cidr.test_cidr_2,
          on terraform_plugin_test.tf line 34, in resource "aws_vpc_ipam_pool_cidr" "test_cidr_2":
          34: resource "aws_vpc_ipam_pool_cidr" "test_cidr_2" {


        Error: creating IPAM Pool (ipam-pool-0c4c11e0a0f45f1be) CIDR: InvalidParameterCombination: The request must contain a CIDR Authorization Context for ipam-pool-0c4c11e0a0f45f1be. The specified pool belongs to a public scope where the specified CIDR has not previously been provisioned.
        	status code: 400, request id: 1de43236-1e53-43c5-bf9c-39c0ea701528

          with aws_vpc_ipam_pool_cidr.test_cidr_3,
          on terraform_plugin_test.tf line 39, in resource "aws_vpc_ipam_pool_cidr" "test_cidr_3":
          39: resource "aws_vpc_ipam_pool_cidr" "test_cidr_3" {


        Error: creating IPAM Pool (ipam-pool-0c4c11e0a0f45f1be) CIDR: InvalidParameterCombination: The request must contain a CIDR Authorization Context for ipam-pool-0c4c11e0a0f45f1be. The specified pool belongs to a public scope where the specified CIDR has not previously been provisioned.
        	status code: 400, request id: 6a99e112-ee23-46e4-9d4b-9a47df84b42f

          with aws_vpc_ipam_pool_cidr.test_cidr_4,
          on terraform_plugin_test.tf line 44, in resource "aws_vpc_ipam_pool_cidr" "test_cidr_4":
          44: resource "aws_vpc_ipam_pool_cidr" "test_cidr_4" {

--- FAIL: TestAccVPCPublicIpv4PoolsDataSource_filter (73.49s)

@github-actions
Copy link

github-actions bot commented Dec 6, 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 the documentation Introduces or discusses updates to documentation. label Dec 6, 2022
Scott Reu added 2 commits December 7, 2022 14:58
This reverts commit 016659a.
… github.com:gatsbysghost/terraform-provider-aws into f-aws_ec2_vpc_public_ipv4_pools_data_source"

This reverts commit 5121550, reversing
changes made to 54f1b9a.
@github-actions github-actions bot added service/controltower Issues and PRs that pertain to the controltower service. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. service/medialive Issues and PRs that pertain to the medialive service. service/meta service/resourceexplorer2 Issues and PRs that pertain to the resourceexplorer2 service. service/simpledb Issues and PRs that pertain to the simpledb service. service/sts Issues and PRs that pertain to the sts service. service/vpc Issues and PRs that pertain to the vpc service. tags Pertains to resource tagging. and removed service/pipes Issues and PRs that pertain to the pipes service. service/dms Issues and PRs that pertain to the dms service. service/efs Issues and PRs that pertain to the efs service. service/evidently Issues and PRs that pertain to the evidently service. service/glue Issues and PRs that pertain to the glue service. service/transitgateway Issues and PRs that pertain to the transitgateway service. verify Pertains to the verify package (i.e., provider-level validating, diff suppression, etc.) linter Pertains to changes to or issues with the various linters. client-connections Pertains to the AWS Client and service connections. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. github_actions Pull requests that update Github_actions code service/networkmanager Issues and PRs that pertain to the networkmanager service. labels Dec 7, 2022
@theonlymalwhere
Copy link
Contributor Author

Sorry, created a small gitastrophe trying to rebase.

@theonlymalwhere
Copy link
Contributor Author

Honestly not worth it to fix this branch, I'm just going to kill it & start a new one. Sorry for being a doofus with git!

@github-actions github-actions bot removed the needs-triage Waiting for first response or review from a maintainer. label Dec 7, 2022
@github-actions
Copy link

github-actions bot commented Jan 7, 2023

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 Jan 7, 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. provider Pertains to the provider itself, rather than any interaction with AWS. service/controltower Issues and PRs that pertain to the controltower service. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. service/medialive Issues and PRs that pertain to the medialive service. service/resourceexplorer2 Issues and PRs that pertain to the resourceexplorer2 service. service/simpledb Issues and PRs that pertain to the simpledb service. service/sts Issues and PRs that pertain to the sts service. service/vpc Issues and PRs that pertain to the vpc service. size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. tags Pertains to resource tagging. 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.

9 participants