aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
12.16k stars 4.14k forks source link

(@aws-cdk/aws-ec2-alpha): IPAM PoolOptions missing options from AWS::EC2::IPAMPool #34178

Open pemattr opened 3 weeks ago

pemattr commented 3 weeks ago

Describe the bug

https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.PoolOptions.html#properties https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html

Currently the Interface is missing a few options from the CFN construct. The key one being SourceIpamPoolId allowing you to create pools within pools.

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

The L2 construct should support all the options

Current Behavior

No SourceIpamPoolId option exists

Reproduction Steps

N/A

Possible Solution

The option could be added to PoolOptions or a method could be attached to IIpamPool called addPool or similar allowing you to create a pool from the created construct. Or both?

Additional Information/Context

No response

CDK CLI Version

2.1010.0 (build 6b421db)

Framework Version

No response

Node.js Version

v22.14.0

OS

Windows 11 WSL2 Ubuntu 24.04.2 LTS

Language

TypeScript

Language Version

No response

Other information

No response

pahud commented 3 weeks ago

Hi @pemattr,

Thanks for reporting this issue and providing detailed information!

You've correctly identified a feature gap in the @aws-cdk/aws-ec2-alpha PoolOptions interface. It currently lacks the SourceIpamPoolId property, which is available in the underlying AWS::EC2::IPAMPool CloudFormation resource and is necessary for creating nested IPAM pools.

It's important to note that while the CDK aims to provide convenient L2 constructs, not all properties from the underlying L1 CloudFormation resources are automatically exposed. Enhancements like adding SourceIpamPoolId often require specific contributions to map the property and integrate it into the L2 construct's logic.

The definition for PoolOptions is located in the ipam-pool.ts file within the packages/@aws-cdk/aws-ec2-alpha/lib/ directory. Adding the sourceIpamPoolId property to this interface seems like the appropriate way forward. Conceptually, the change would look something like this:

// Conceptual fix - adding the property to PoolOptions
// Likely file: packages/@aws-cdk/aws-ec2-alpha/lib/ipam-pool.ts

export interface PoolOptions {
  // ... existing options like addressFamily, allocationDefaultNetmaskLength, etc. ...

  /**
   * The ID of the source IPAM pool. Use this option to create a pool within an existing pool.
   * @default - Pool is created at the top level.
   */
  readonly sourceIpamPoolId?: string;

  // ... potentially other missing options ...
}

We truly appreciate community contributions and welcome Pull Requests! If you're interested in submitting a PR to add this property (and potentially other missing options), the CDK team would be happy to review it. Please refer to the AWS CDK Contributing Guide for more details on the process.

In the meantime, adding an upvote (👍 reaction) to the issue can help the team gauge community interest and prioritize this feature request.

Thanks again for bringing this to our attention! Let us know if you have any other questions.

sbeginCoveo commented 1 week ago

An interesting alternative could be to implement the same addPool function that's available on scopes, making the reference implicit.