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

[Bug]: data.aws_vpc_ipam_pools only returns one result #40314

Open
fsmedw opened this issue Nov 26, 2024 · 2 comments
Open

[Bug]: data.aws_vpc_ipam_pools only returns one result #40314

fsmedw opened this issue Nov 26, 2024 · 2 comments
Labels
bug Addresses a defect in current functionality. service/ipam Issues and PRs that pertain to the ipam service.

Comments

@fsmedw
Copy link

fsmedw commented Nov 26, 2024

Terraform Core Version

1.7.5, 1.9.8

AWS Provider Version

5.77, 5.4, 5.0, 4.67

Affected Resource(s)

data.aws_vpc_ipam_pools

Expected Behavior

Documentation suggest that this resource returns a list of IPAM pools:

ipam_pools - List of IPAM pools and their attributes. See below for details

Actual Behavior

The list of pools only contains a single entry, the first in the list it gets from AWS API, and seems to be a set rather than a list.

Terraform debug output shows that the API returns multiple pools, as does aws cli.

Relevant Error/Panic Output Snippet

❯ terraform plan

data.aws_vpc_ipam_pools.pools: Reading...
data.aws_vpc_ipam_pools.pools: Read complete after 0s [id=eu-west-1]

Changes to Outputs:
  + pools = {
      + filter     = null
      + id         = "eu-west-1"
      + ipam_pools = [
          + {
              + address_family                    = "ipv4"
              + allocation_default_netmask_length = 16
              + allocation_max_netmask_length     = 0
              + allocation_min_netmask_length     = 0
              + allocation_resource_tags          = {}
              + arn                               = "xxx"
              + auto_import                       = true
              + aws_service                       = ""
              + description                       = "xxx"
              + id                                = "xxx"
              + ipam_scope_id                     = "xxx"
              + ipam_scope_type                   = "private"
              + locale                            = "eu-west-1"
              + pool_depth                        = 2
              + publicly_advertisable             = false
              + source_ipam_pool_id               = "xxx"
              + state                             = "create-complete"
              + tags                              = {}
            },
        ]
    }

Terraform Configuration Files

data "aws_vpc_ipam_pools" "pools" {}

output "pools" {
  value = data.aws_vpc_ipam_pools.pools
}

Steps to Reproduce

Have multiple IPAM pools in your account and run terraform plan with the above.

Debug Output

  | <DescribeIpamPoolsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
  |     <requestId>e025365f-5520-419a-859d-6d0e8c5fbc89</requestId>
  |     <ipamPoolSet>
  |         <item>
... hiding pool output
  |         </item>
  |         <item>
... hiding pool output
  |         </item>
    | [truncated...]

Panic Output

No response

Important Factoids

In this issue the pools output shows multiple pools: #32106

Docs also say that a filter is required but it works without one. Issue persists even if using a filter.

References

No response

Would you like to implement a fix?

No

@fsmedw fsmedw added the bug Addresses a defect in current functionality. label Nov 26, 2024
@github-actions github-actions bot added the service/ipam Issues and PRs that pertain to the ipam service. label Nov 26, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 26, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jan 29, 2025
@plundra
Copy link

plundra commented Feb 3, 2025

@fsmedw I've ran with this local patch for a long time; never got around to make PR... Sorry for that, figured it'd be a hassle to fix tests :-)
Hope it helps. I was surprised that it wasn't affecting others since I hit it first time using the IPAM-stuff even.

diff --git a/internal/service/ec2/ipam_pools_data_source.go b/internal/service/ec2/ipam_pools_data_source.go
index 649fb7121f..58d0f1fffb 100644
--- a/internal/service/ec2/ipam_pools_data_source.go
+++ b/internal/service/ec2/ipam_pools_data_source.go
@@ -26,7 +26,7 @@ func dataSourceIPAMPools() *schema.Resource {
 		Schema: map[string]*schema.Schema{
 			names.AttrFilter: customFiltersSchema(),
 			"ipam_pools": {
-				Type:     schema.TypeSet,
+				Type:     schema.TypeList,
 				Computed: true,
 				Elem: &schema.Resource{
 					Schema: map[string]*schema.Schema{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/ipam Issues and PRs that pertain to the ipam service.
Projects
None yet
Development

No branches or pull requests

3 participants