Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addressing last comments
Browse files Browse the repository at this point in the history
shikha372 committed Jan 27, 2025
1 parent 0de3fd3 commit 9f997a6
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2-alpha/README.md
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ Ref: https://docs.aws.amazon.com/cli/latest/reference/ec2/get-ipam-pool-allocati

const stack = new Stack();
const ipam = new Ipam(this, 'Ipam', {
operatingRegion: ['us-west-1']
operatingRegions: ['us-west-1']
});
const ipamPublicPool = ipam.publicScope.addPool('PublicPoolA', {
addressFamily: AddressFamily.IP_V6,
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ export interface IpamProps {
*
* @default - Stack.region if defined in the stack
*/
readonly operatingRegion?: string[];
readonly operatingRegions?: string[];

/**
* Name of IPAM that can be used for tagging resource
@@ -511,11 +511,11 @@ export class Ipam extends Resource {
if (props?.ipamName) {
Tags.of(this).add(NAME_TAG, props.ipamName);
}
if (props?.operatingRegion && (props.operatingRegion.length === 0)) {
if (props?.operatingRegions && (props.operatingRegions.length === 0)) {
throw new Error('Please provide at least one operating region');
}

this.operatingRegions = props?.operatingRegion ?? [Stack.of(this).region];
this.operatingRegions = props?.operatingRegions ?? [Stack.of(this).region];
this.ipamName = props?.ipamName;

this._ipam = new CfnIPAM(this, 'Ipam', {
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 {
}
this.addDefaultInternetRoute(subnet, igw, options);
processedSubnets.add(subnet.node.id);
};
}
}); // If there are no input subnets defined, default route will be added to all public subnets
} else if (!options?.subnets && this.publicSubnets) {
this.publicSubnets.forEach((publicSubnets) => this.addDefaultInternetRoute(publicSubnets, igw, options));
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2-alpha/test/integ.ipam.ts
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-vpcv2-alpha-integ-ipam');

const ipam = new Ipam(stack, 'IpamTest', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});

/** Test Ipam Pool Ipv4 */
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ const natgw = vpc.addNatGateway({
natgw.node.addDependency(vpnGateway);

const ipam = new Ipam(stack, 'IpamIntegTest', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
ipamName: 'CDKIpamTestTag',
});

14 changes: 7 additions & 7 deletions packages/@aws-cdk/aws-ec2-alpha/test/ipam.test.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ describe('IPAM Test', () => {
env: envUSA,
});
ipam = new Ipam(stack, 'Ipam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
});

@@ -82,7 +82,7 @@ describe('IPAM Test', () => {
test('Creates IPAM CIDR pool under public scope for IPv6', () => {
// Create IPAM resources
const ipamIpv6 = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
const poolOptions: vpc.PoolOptions = {
addressFamily: AddressFamily.IP_V6,
@@ -116,7 +116,7 @@ describe('IPAM Test', () => {
test('Get region from stack env', () => {
// Create IPAM resources
const ipamRegion = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
const poolOptions: vpc.PoolOptions = {
addressFamily: AddressFamily.IP_V6,
@@ -158,7 +158,7 @@ describe('IPAM Test', () => {
test('IPAM throws error if awsService is not provided for IPv6 address', () => {
// Create IPAM resources
const ipamRegion = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
const poolOptions: vpc.PoolOptions = {
addressFamily: AddressFamily.IP_V6,
@@ -172,15 +172,15 @@ describe('IPAM Test', () => {
const app = new cdk.App();
const stack_new = new cdk.Stack(app, 'TestStack');
expect(() => new Ipam(stack_new, 'TestIpam', {
operatingRegion: [],
operatingRegions: [],
})).toThrow('Please provide at least one operating region');
});

test('IPAM infers region from provided operating region correctly', () => {
const app = new cdk.App();
const stack_new = new cdk.Stack(app, 'TestStack');
new Ipam(stack_new, 'TestIpam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
Template.fromStack(stack_new).hasResourceProperties(
'AWS::EC2::IPAM', {
@@ -231,7 +231,7 @@ describe('IPAM Test', () => {

test('IPAM throws error if locale(region) of pool is not one of the operating regions', () => {
const ipamRegion = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-2'],
operatingRegions: ['us-west-2'],
});
const poolOptions: vpc.PoolOptions = {
addressFamily: AddressFamily.IP_V6,
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2-alpha/test/subnet-v2.test.ts
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ describe('Subnet V2 with custom IP and routing', () => {

test('Create Subnet with IPv6 if it is Ipam Ipv6 is enabled on VPC', () => {
const ipam = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
});
const pool = ipam.publicScope.addPool('PublicPool0', {
addressFamily: AddressFamily.IP_V6,
@@ -244,7 +244,7 @@ describe('Subnet V2 with custom IP and routing', () => {

test('Should throw error if overlapping CIDR block(IPv6) for the subnet', () => {
const ipam = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
});
const pool = ipam.publicScope.addPool('PublicPool0', {
addressFamily: AddressFamily.IP_V6,
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2-alpha/test/vpc-tagging.test.ts
Original file line number Diff line number Diff line change
@@ -276,7 +276,7 @@ describe('Vpc V2 with full control', () => {
test('Adds tag to IPAM and IPAM Scope and Pool', () => {
const ipam = new Ipam(stack, 'TestIpam', {
ipamName: 'TestIpam',
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
});

ipam.addScope(stack, 'TestScope', {
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-ec2-alpha/test/vpc-v2.test.ts
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ describe('Vpc V2 with full control', () => {
test('VPC Primary IP from Ipv4 Ipam', () => {

const ipam = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
});

const pool = ipam.privateScope.addPool('PrivatePool0', {
@@ -178,7 +178,7 @@ describe('Vpc V2 with full control', () => {

test('VPC Secondary IP from Ipv6 Ipam', () => {
const ipam = new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
});

const pool = ipam.publicScope.addPool('PublicPool0', {
@@ -311,7 +311,7 @@ describe('Vpc V2 with full control', () => {
primaryAddressBlock: vpc.IpAddresses.ipv4('10.1.0.0/16'),
secondaryAddressBlocks: [vpc.IpAddresses.ipv6Ipam({
ipamPool: new Ipam(stack, 'TestIpam', {
operatingRegion: ['us-west-1'],
operatingRegions: ['us-west-1'],
}).publicScope.addPool('PublicPool0', {
addressFamily: AddressFamily.IP_V6,
awsService: AwsServiceName.EC2,

0 comments on commit 9f997a6

Please sign in to comment.