Skip to content

feat(ec2-alpha): nested ipam pool # #34359

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ export interface PoolOptions {
* @default - autogenerated by CDK if not provided
*/
readonly ipamPoolName?: string;

/**
* 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;
}

const NAME_TAG: string = 'Name';
Expand Down Expand Up @@ -359,6 +365,7 @@ class IpamPool extends Resource implements IIpamPool {
ipamScopeId: props.ipamScopeId,
publicIpSource: props.publicIpSource,
awsService: props.awsService,
sourceIpamPoolId: props.sourceIpamPoolId,
});
this.ipamPoolId = this._ipamPool.attrIpamPoolId;

Expand Down Expand Up @@ -594,5 +601,6 @@ function createIpamPool(
locale: poolOptions.locale,
publicIpSource: poolOptions.publicIpSource,
awsService: poolOptions.awsService,
sourceIpamPoolId: poolOptions.sourceIpamPoolId,
});
}
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/test/ipam.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ describe('IPAM Test', () => {
); // End Template
});

test('Creates nested IP Pools', () => {
const pool = ipam.privateScope.addPool('Private', {
addressFamily: vpc.AddressFamily.IP_V4,
ipv4ProvisionedCidrs: ['10.2.0.0/14'],
locale: 'us-west-2',
});
ipam.privateScope.addPool('PrivateChild', {
addressFamily: vpc.AddressFamily.IP_V4,
ipv4ProvisionedCidrs: ['10.2.0.0/16'],
sourceIpamPoolId: pool.ipamPoolId,
});

Template.fromStack(stack).hasResourceProperties(
'AWS::EC2::IPAMPool',
{
AddressFamily: 'ipv4',
SourceIpamPoolId: { 'Fn::GetAtt': ['IpamPrivate4E8D7A02', 'IpamPoolId'] },
},
);
});

test('Creates IPAM CIDR pool under public scope for IPv6', () => {
// Create IPAM resources
const ipamIpv6 = new Ipam(stack, 'TestIpam', {
Expand Down