Skip to content

Can't delete IPAM pool (says there is an allocation to VPC)

0

TL;DR: IPAM pool allocations shows allocation to a VPC, so I can't delete the IPAM pool. But VPC has no CIDR. Am I stuck in a deadlock?

I'm playing with IPAM and created a parent IPAM pool ipam-pool-1, then a child IPAM pool ipam-pool-2. I associated this child IPAM pool ipam-pool-2 to an existing VPC vpc-1 to see how it works. Now I wan't to delete all my IPAM pools (to start afresh with other netmask length) but to do this I need to delete CIDR of each one.

When I try to delete CIDR from ipam-pool-2 I get:

Failed deprovision (The CIDR has one or more allocations.)

Indeed the "Allocations" (of IPAM pool) tab shows an allocation to VPC vpc-1.

But this tab don't offer way to delete such allocation.

And the VPC has no CIDR, AWS CLI confirms this: the all returned associations are in "disassociated" state.

$ aws ec2 describe-vpcs
{
    "Vpcs": [
        {
            "VpcId": "vpc-1",
            "Ipv6CidrBlockAssociationSet": [
                {
                    "AssociationId": "vpc-cidr-assoc-0830cf26e3e292af8",
                    "Ipv6CidrBlock": "2a05:d012:474:2700::/56",
                    "Ipv6CidrBlockState": {
                        "State": "disassociated"
                    },
                    "NetworkBorderGroup": "eu-west-3",
                    "Ipv6Pool": "Amazon",
                    "Ipv6AddressAttribute": "public",
                    "IpSource": "amazon"
                },
                {
                    "AssociationId": "vpc-cidr-assoc-0ff5848dddcabfba3",
                    "Ipv6CidrBlock": "2a05:d022:f::/56",
                    "Ipv6CidrBlockState": {
                        "State": "disassociated"
                    },
                    "NetworkBorderGroup": "eu-west-3",
                    "Ipv6Pool": "IPAM Managed",
                    "Ipv6AddressAttribute": "public",
                    "IpSource": "amazon"
                },
                {
                    "AssociationId": "vpc-cidr-assoc-0461c03f7676c080a",
                    "Ipv6CidrBlock": "2a05:d012:d8f:8a00::/56",
                    "Ipv6CidrBlockState": {
                        "State": "disassociated"
                    },
                    "NetworkBorderGroup": "eu-west-3",
                    "Ipv6Pool": "Amazon",
                    "Ipv6AddressAttribute": "public",
                    "IpSource": "amazon"
                }
            ]
        }
    ]

If I try to use AWS CLI to release the IPAM pool allocation I get an error:

$ aws ec2 get-ipam-pool-allocations --ipam-pool-id ipam-pool-2
{
    "IpamPoolAllocations": [
        {
            "Cidr": "2a05:d022:f::/56",
            "IpamPoolAllocationId": "ipam-pool-alloc-034811",
            "ResourceId": "vpc-1",
            "ResourceType": "vpc",
            "ResourceRegion": "eu-west-3",
            "ResourceOwner": "8…"
        }
    ]
}


$ aws ec2 release-ipam-pool-allocation --ipam-pool-id ipam-pool-2  --cidr "2a05:d022:f::/56" --ipam-pool-allocation-id "ipam-pool-alloc-034811"
An error occurred (InvalidParameterValue) when calling the ReleaseIpamPoolAllocation operation: The allocation ID ipam-pool-alloc-1 is not valid. Cannot release allocation for resource type VPC.

What am I missing?

  • Is there a long delay for resource to be actually removed from VPC?

    The documentation about IPAM allocation releasing states we need to wait 48 hours but it's for re-using the CIDR (and I don't specially want to reuse them):

    When you release a CIDR that’s managed by your IPAM, Amazon VPC IPAM recycles the CIDR back into an IPAM pool. If you are using IPAM in the Advanced Tier, it takes a few minutes for the CIDR to become available for future allocations. If you are using IPAM in the Free Tier, it will take up to 48 hours for the CIDR to become available for future allocations.

asked a year ago497 views

5 Answers
1

It seems you just have to wait (24h?).

CIDR I could not de-provision yesterday because of existing allocation with a VPC are now allocation-free and thus de-provision-able.

answered a year ago

  • Thanks for confirming — sounds like IPAM eventually auto-released the allocation after some delay, even without deleting the VPC.

0

When you're trying to delete an IPAM pool but encountering issues due to allocations, you're facing a common challenge with IPAM resource management. Here's how to resolve this situation:

The error you're seeing occurs because you cannot delete an IPAM pool if there are allocations in it or CIDRs provisioned to it, even if the VPC shows the CIDR associations as "disassociated".

To resolve this issue, you have two options:

  1. Release the allocation first, then delete the pool:
  • Use the release-ipam-pool-allocation command to release the allocation from your VPC
  • You'll need the IPAM pool ID and the allocation ID, which you can get with describe-ipam-pools and get-ipam-pool-allocations commands
  • After releasing the allocation, you can deprovision the CIDR and then delete the pool
  1. Use the cascade option to delete everything at once:
  • When deleting the IPAM pool, you can use the --cascade option with the delete-ipam-pool command
  • This will automatically release any allocations in the pool before deleting it
  • This is useful when you don't want to remove allocations one by one

Note that when you release a CIDR that's managed by IPAM, it takes time for the CIDR to become available for future allocations - a few minutes in the Advanced Tier or up to 48 hours in the Free Tier.

For manual allocations specifically, you must either ignore/delete the resource CIDR (for private scope) or delete the resource CIDR (for public scope) before the allocation can be fully released.

Make sure to run these commands in the region that matches the locale of your IPAM pool.
Sources
DeleteIpamPool - Amazon Elastic Compute Cloud
delete-ipam-pool — AWS CLI 2.27.41 Command Reference
Release an allocation - Amazon Virtual Private Cloud
release-ipam-pool-allocation — AWS CLI 2.27.41 Command Reference
Amazon EC2 examples using AWS CLI - AWS SDK Code Examples

answered a year ago

  • I cannot cascale delete the IPAM pool, because it is "part of a public scope".

    $ aws ec2 delete-ipam-pool --ipam-pool-id ipam-pool-2 --cascade
    
    An error occurred (InvalidParameterValue) when calling the DeleteIpamPool operation: ipam-pool: ipam-pool-2 is part of a public scope and cannot be cascade deleted.
    
0

Hi,

Just a quick note — IPAM pools work in both private and public scopes, but only pools in the private scope can be cascade deleted.

AWS doc:-

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/delete_ipam_pool.html

Boto3 doc delete_ipam_pool:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/delete_ipam_pool.html

Best

answered a year ago

  • OK. But how can I manually find associations/allocations of those public pools in order to manually deassociate/deallocate+delete them?

0

hi, have you deleted the VPC?

wait few minutes to see the IPAM Auto-release the allocation ( IPAM should automatically release onces the VPC deleted.

doc: https://docs.aws.amazon.com/vpc/latest/ipam/release-alloc-ipam.html#auto-release

i thought i copy past this doc in my previous answer, i should have asked you this before.

Best

answered a year ago

  • I did not delete the VPC (and don't want to).

0

ok! got it.

you have already looked into it, but just in case:

To find commands references help for IPAM:

https://docs.aws.amazon.com/cli/latest/reference/ec2/

Look under these sections:

get-ipam-pool-allocations

deprovision-ipam-pool-cidr

delete-ipam-pool

release-ipam-pool-allocation

Use Find Ctrl+F on page to quick search.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.