Skip to content

Commit 84da786

Browse files
committed
feat(ec2): make netmaskLength optional in IPAM allocation interfaces and update documentation
1 parent fb71ff2 commit 84da786

File tree

5 files changed

+149
-51
lines changed

5 files changed

+149
-51
lines changed
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
import { SubnetIpamTest, SubnetIpamIntegTest } from './integ.subnet-ipam';
22

3-
// 既存テストスタックの説明
3+
// Description of the existing test stack
44
const literalOutput = `
5-
# サブネットの機能とIPv6のサポート
5+
# Subnet Features and IPv6 Support
66
7-
このテストは、AWS CDKでのサブネットの基本機能とIPv6サポートのテスト例です。
8-
また、将来的な機能として実装予定のIPAM(IP Address Manager)機能についても説明しています。
7+
This test demonstrates basic subnet functionality and IPv6 support in AWS CDK.
8+
It also explains the IPAM (IP Address Manager) features that will be implemented.
99
10-
## テスト内容
10+
## Test Contents
1111
12-
1. **基本的なサブネットの作成**
13-
- VPC内に標準的なIPv4サブネットを作成
14-
- 固定のCIDRブロックを使用
12+
1. **Basic Subnet Creation**
13+
- Creating a standard IPv4 subnet within a VPC
14+
- Using fixed CIDR blocks
1515
16-
2. **IPv6サポートの有効化**
17-
- 2つ目のサブネットでIPv6アドレスの自動割り当てを有効化
18-
- デュアルスタック(IPv4/IPv6)構成の検証
16+
2. **IPv6 Support Enablement**
17+
- Enabling automatic IPv6 address assignment on a second subnet
18+
- Validating dual-stack (IPv4/IPv6) configuration
1919
20-
## 将来の機能: IPAM (IP Address Manager) 統合
20+
## Future Feature: IPAM (IP Address Manager) Integration
2121
22-
AWS IP Address Manager (IPAM) の統合により、以下の機能が利用可能になる予定です:
22+
AWS IP Address Manager (IPAM) integration will enable the following features:
2323
24-
- IPv4およびIPv6アドレス空間を一元管理
25-
- IPAMプールからCIDRを動的に割り当て
26-
- 使用中のCIDRブロックの重複を防止
27-
- IPアドレスの割り当て履歴を追跡
24+
- Centralized management of IPv4 and IPv6 address space
25+
- Dynamic allocation of CIDRs from IPAM pools
26+
- Prevention of CIDR block overlaps in use
27+
- Tracking of IP address allocation history
2828
29-
IPAM機能の例(将来のリリースで実装予定):
29+
IPAM feature examples (to be implemented in future releases):
3030
3131
\`\`\`typescript
32-
// IPv4 IPAM割り当てを使用したサブネット
32+
// Subnet using IPv4 IPAM allocation
3333
const subnet = new ec2.Subnet(stack, 'Subnet', {
3434
vpcId: vpc.vpcId,
3535
availabilityZone: vpc.availabilityZones[0],
3636
ipv4IpamAllocation: {
37-
ipamPoolId: 'ipam-pool-id', // 実際のIPAMプールID
38-
netmaskLength: 24,
37+
ipamPoolId: 'ipam-pool-id', // Actual IPAM pool ID
38+
netmaskLength: 24, // Optional: If not specified, the default netmask length from the IPAM pool will be used
3939
},
4040
});
4141
42-
// IPv6 IPAM割り当てを使用したサブネット
42+
// Subnet using IPv6 IPAM allocation
4343
const subnetIpv6 = new ec2.Subnet(stack, 'SubnetIpv6', {
4444
vpcId: vpc.vpcId,
4545
availabilityZone: vpc.availabilityZones[1],
4646
cidrBlock: '10.0.1.0/24',
4747
assignIpv6AddressOnCreation: true,
4848
ipv6IpamAllocation: {
49-
ipamPoolId: 'ipam-pool-id', // 実際のIPAMプールID
50-
netmaskLength: 64,
49+
ipamPoolId: 'ipam-pool-id', // Actual IPAM pool ID
50+
// netmaskLength is optional
5151
},
5252
});
5353
\`\`\`
5454
55-
## テスト実行方法
55+
## Test Execution Method
5656
57-
このテストは合成のみを行い、実際のデプロイは実行しません。
58-
IPAM機能を実際にテストするには、AWS組織内で設定されたIPAMプールが必要です。
57+
This test only performs synthesis and does not actually deploy.
58+
To actually test IPAM features, you need an IPAM pool configured within your AWS organization.
5959
`;
6060

61-
// スタックをリエクスポート
61+
// Re-export stacks
6262
export = { SubnetIpamTest, SubnetIpamIntegTest, literalOutput };

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.subnet-ipam.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,26 @@ const app = new cdk.App();
66

77
/**
88
* Test stack - Examples of using IPAM features with Subnets
9-
* テストスタック - サブネットでIPAM機能を使用する例
109
*/
1110
export class SubnetIpamTestStack extends cdk.Stack {
1211
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
1312
super(scope, id, props);
1413

1514
// Create a VPC first
16-
// まず、VPCを作成
1715
const vpc = new ec2.Vpc(this, 'TestVpc', {
1816
maxAzs: 2,
1917
natGateways: 0,
2018
subnetConfiguration: [],
2119
});
2220

2321
// Basic IPv4 subnet with CIDR block
24-
// 基本的なIPv4 CIDRブロックを使用したサブネット
2522
const subnetWithIpv4 = new ec2.Subnet(this, 'SubnetWithIpv4', {
2623
vpcId: vpc.vpcId,
2724
availabilityZone: vpc.availabilityZones[0],
2825
cidrBlock: '10.0.0.0/24',
2926
});
3027

3128
// IPv4 subnet with public IP mapping enabled
32-
// パブリックIPマッピングを有効にしたIPv4サブネット
3329
const subnetWithPublicIp = new ec2.Subnet(this, 'SubnetWithPublicIp', {
3430
vpcId: vpc.vpcId,
3531
availabilityZone: vpc.availabilityZones[0],
@@ -38,7 +34,6 @@ export class SubnetIpamTestStack extends cdk.Stack {
3834
});
3935

4036
// IPv4 subnet with IPv6 CIDR block
41-
// IPv6 CIDRブロックを追加したIPv4サブネット
4237
const subnetWithIpv6 = new ec2.Subnet(this, 'SubnetWithIpv6', {
4338
vpcId: vpc.vpcId,
4439
availabilityZone: vpc.availabilityZones[1],
@@ -48,9 +43,7 @@ export class SubnetIpamTestStack extends cdk.Stack {
4843
});
4944

5045
// Test IPAM allocation using CloudFormation intrinsic functions
51-
// CloudFormation組み込み関数を使用してIPAM割り当てをテスト
5246
// IPv4 IPAM allocation - using token to simulate an IPAM pool ID
53-
// IPv4 IPAM割り当て - トークンを使用してIPAMプールIDをシミュレート
5447
const ipamPoolIdIpv4 = new cdk.CfnParameter(this, 'IpamPoolIdIpv4', {
5548
type: 'String',
5649
default: 'ipam-pool-0example0123456789',
@@ -67,7 +60,6 @@ export class SubnetIpamTestStack extends cdk.Stack {
6760
});
6861

6962
// IPv6 IPAM allocation - using token to simulate an IPAM pool ID
70-
// IPv6 IPAM割り当て - トークンを使用してIPAMプールIDをシミュレート
7163
const ipamPoolIdIpv6 = new cdk.CfnParameter(this, 'IpamPoolIdIpv6', {
7264
type: 'String',
7365
default: 'ipam-pool-0example9876543210',
@@ -86,7 +78,6 @@ export class SubnetIpamTestStack extends cdk.Stack {
8678
});
8779

8880
// Combined IPv4 and IPv6 IPAM allocations
89-
// IPv4とIPv6の両方のIPAM割り当て
9081
const subnetWithBothIpamAllocations = new ec2.Subnet(this, 'SubnetWithBothIpamAllocations', {
9182
vpcId: vpc.vpcId,
9283
availabilityZone: vpc.availabilityZones[0],
@@ -101,8 +92,22 @@ export class SubnetIpamTestStack extends cdk.Stack {
10192
assignIpv6AddressOnCreation: true,
10293
});
10394

95+
// IPv4 and IPv6 IPAM allocations without netmaskLength
96+
const subnetWithIpamAllocationsWithoutNetmask = new ec2.Subnet(this, 'SubnetWithIpamAllocationsWithoutNetmask', {
97+
vpcId: vpc.vpcId,
98+
availabilityZone: vpc.availabilityZones[1],
99+
ipv4IpamAllocation: {
100+
ipamPoolId: ipamPoolIdIpv4.valueAsString,
101+
// netmaskLength is optional and will use the IPAM pool's default
102+
},
103+
ipv6IpamAllocation: {
104+
ipamPoolId: ipamPoolIdIpv6.valueAsString,
105+
// netmaskLength is optional and will use the IPAM pool's default
106+
},
107+
assignIpv6AddressOnCreation: true,
108+
});
109+
104110
// Output the subnet IDs for reference
105-
// 参照用にサブネットIDを出力
106111
// Basic IPv4 subnet
107112
new cdk.CfnOutput(this, 'IPv4SubnetId', {
108113
value: subnetWithIpv4.subnetId,
@@ -138,19 +143,22 @@ export class SubnetIpamTestStack extends cdk.Stack {
138143
value: subnetWithBothIpamAllocations.subnetId,
139144
description: 'The subnet ID of the subnet with both IPv4 and IPv6 IPAM allocations',
140145
});
146+
147+
// IPv4 and IPv6 IPAM allocations without netmaskLength subnet
148+
new cdk.CfnOutput(this, 'IpamAllocationsWithoutNetmaskSubnetId', {
149+
value: subnetWithIpamAllocationsWithoutNetmask.subnetId,
150+
description: 'The subnet ID of the subnet with IPv4 and IPv6 IPAM allocations without netmaskLength',
151+
});
141152
}
142153
}
143154

144155
// Create an instance of the test stack
145-
// テストスタックのインスタンスを作成
146156
export const SubnetIpamTest = new SubnetIpamTestStack(app, 'SubnetIpamTest');
147157

148158
// Create an IntegTest (for CDK Integration Test framework)
149-
// IntegTestを作成(CDKのIntegration Testフレームワーク用)
150159
export const SubnetIpamIntegTest = new IntegTest(app, 'SubnetIpamIntegTest', {
151160
testCases: [SubnetIpamTest],
152161
// This test only performs synthesis and does not actually deploy
153-
// このテストは合成のみを行い、実際のデプロイは実行しない
154162
cdkCommandOptions: {
155163
deploy: {
156164
enabled: false,

packages/aws-cdk-lib/aws-ec2/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ new ec2.Subnet(this, 'Subnet', {
26212621
availabilityZone: 'us-east-1a',
26222622
ipv4IpamAllocation: {
26232623
ipamPoolId: 'ipam-pool-12345',
2624-
netmaskLength: 24,
2624+
netmaskLength: 24, // Optional: if not specified, uses the default netmask length from the IPAM pool
26252625
},
26262626
});
26272627
```
@@ -2636,7 +2636,7 @@ new ec2.Subnet(this, 'Subnet', {
26362636
cidrBlock: '10.0.0.0/24', // IPv4 CIDR is required
26372637
ipv6IpamAllocation: {
26382638
ipamPoolId: 'ipam-pool-67890',
2639-
netmaskLength: 64,
2639+
netmaskLength: 64, // Optional: if not specified, uses the default netmask length from the IPAM pool
26402640
},
26412641
assignIpv6AddressOnCreation: true,
26422642
});
@@ -2651,11 +2651,11 @@ new ec2.Subnet(this, 'Subnet', {
26512651
availabilityZone: 'us-east-1a',
26522652
ipv4IpamAllocation: {
26532653
ipamPoolId: 'ipam-pool-12345',
2654-
netmaskLength: 24,
2654+
// netmaskLength is optional and will use the IPAM pool's default if not specified
26552655
},
26562656
ipv6IpamAllocation: {
26572657
ipamPoolId: 'ipam-pool-67890',
2658-
netmaskLength: 64,
2658+
// netmaskLength is optional and will use the IPAM pool's default if not specified
26592659
},
26602660
assignIpv6AddressOnCreation: true,
26612661
});
@@ -2665,3 +2665,4 @@ Note that:
26652665
- You cannot specify both `cidrBlock` and `ipv4IpamAllocation` at the same time
26662666
- You cannot specify both `ipv6CidrBlock` and `ipv6IpamAllocation` at the same time
26672667
- If you specify `assignIpv6AddressOnCreation: true`, you must also specify either `ipv6CidrBlock` or `ipv6IpamAllocation`
2668+
- The `netmaskLength` property in both `ipv4IpamAllocation` and `ipv6IpamAllocation` is optional. If not specified, the default netmask length configured in the IPAM pool will be used.

packages/aws-cdk-lib/aws-ec2/lib/vpc.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,8 +1974,12 @@ export interface Ipv4IpamAllocation {
19741974
* The netmask length of the IPv4 CIDR to allocate to the subnet.
19751975
*
19761976
* Valid values are between 16 and 28.
1977+
*
1978+
* If not specified, the default netmask length configured for the IPAM pool will be used.
1979+
*
1980+
* @default - The default netmask length configured in the IPAM pool
19771981
*/
1978-
readonly netmaskLength: number;
1982+
readonly netmaskLength?: number;
19791983
}
19801984

19811985
/**
@@ -1991,8 +1995,12 @@ export interface Ipv6IpamAllocation {
19911995
* The netmask length of the IPv6 CIDR to allocate to the subnet.
19921996
*
19931997
* Valid values are between 48 and 64.
1998+
*
1999+
* If not specified, the default netmask length configured for the IPAM pool will be used.
2000+
*
2001+
* @default - The default netmask length configured in the IPAM pool
19942002
*/
1995-
readonly netmaskLength: number;
2003+
readonly netmaskLength?: number;
19962004
}
19972005

19982006
/**

0 commit comments

Comments
 (0)