@aws-cdk/aws-ec2-alpha 2.158.0-alpha.0 → 2.159.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +799 -344
- package/.jsii.tabl.json.gz +0 -0
- package/.warnings.jsii.js +54 -4
- package/README.md +200 -39
- package/awslint.json +2 -1
- package/lib/ipam.d.ts +17 -9
- package/lib/ipam.js +2 -2
- package/lib/route.d.ts +86 -54
- package/lib/route.js +87 -32
- package/lib/subnet-v2.d.ts +19 -10
- package/lib/subnet-v2.js +14 -7
- package/lib/vpc-v2-base.d.ts +141 -3
- package/lib/vpc-v2-base.js +172 -2
- package/lib/vpc-v2.d.ts +19 -18
- package/lib/vpc-v2.js +5 -9
- package/package.json +7 -7
- package/rosetta/default.ts-fixture +4 -3
package/.jsii.tabl.json.gz
CHANGED
|
Binary file
|
package/.warnings.jsii.js
CHANGED
|
@@ -88,6 +88,36 @@ function _aws_cdk_aws_ec2_alpha_IIpamScopeBase(p) {
|
|
|
88
88
|
}
|
|
89
89
|
function _aws_cdk_aws_ec2_alpha_Ipam(p) {
|
|
90
90
|
}
|
|
91
|
+
function _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGatewayOptions(p) {
|
|
92
|
+
if (p == null)
|
|
93
|
+
return;
|
|
94
|
+
visitedObjects.add(p);
|
|
95
|
+
try {
|
|
96
|
+
if (p.subnets != null)
|
|
97
|
+
for (const o of p.subnets)
|
|
98
|
+
if (!visitedObjects.has(o))
|
|
99
|
+
require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_SubnetSelection(o);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
visitedObjects.delete(p);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function _aws_cdk_aws_ec2_alpha_InternetGatewayOptions(p) {
|
|
106
|
+
}
|
|
107
|
+
function _aws_cdk_aws_ec2_alpha_VPNGatewayV2Options(p) {
|
|
108
|
+
if (p == null)
|
|
109
|
+
return;
|
|
110
|
+
visitedObjects.add(p);
|
|
111
|
+
try {
|
|
112
|
+
if (p.vpnRoutePropagation != null)
|
|
113
|
+
for (const o of p.vpnRoutePropagation)
|
|
114
|
+
if (!visitedObjects.has(o))
|
|
115
|
+
require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_SubnetSelection(o);
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
visitedObjects.delete(p);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
91
121
|
function _aws_cdk_aws_ec2_alpha_IVpcV2(p) {
|
|
92
122
|
}
|
|
93
123
|
function _aws_cdk_aws_ec2_alpha_VpcV2Base(p) {
|
|
@@ -142,27 +172,47 @@ function _aws_cdk_aws_ec2_alpha_InternetGatewayProps(p) {
|
|
|
142
172
|
visitedObjects.delete(p);
|
|
143
173
|
}
|
|
144
174
|
}
|
|
145
|
-
function
|
|
175
|
+
function _aws_cdk_aws_ec2_alpha_VPNGatewayV2Props(p) {
|
|
146
176
|
if (p == null)
|
|
147
177
|
return;
|
|
148
178
|
visitedObjects.add(p);
|
|
149
179
|
try {
|
|
150
180
|
if (!visitedObjects.has(p.vpc))
|
|
151
181
|
_aws_cdk_aws_ec2_alpha_IVpcV2(p.vpc);
|
|
182
|
+
if (p.vpnRoutePropagation != null)
|
|
183
|
+
for (const o of p.vpnRoutePropagation)
|
|
184
|
+
if (!visitedObjects.has(o))
|
|
185
|
+
require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_SubnetSelection(o);
|
|
152
186
|
}
|
|
153
187
|
finally {
|
|
154
188
|
visitedObjects.delete(p);
|
|
155
189
|
}
|
|
156
190
|
}
|
|
157
|
-
function
|
|
191
|
+
function _aws_cdk_aws_ec2_alpha_NatGatewayOptions(p) {
|
|
158
192
|
if (p == null)
|
|
159
193
|
return;
|
|
160
194
|
visitedObjects.add(p);
|
|
161
195
|
try {
|
|
196
|
+
if (!visitedObjects.has(p.subnet))
|
|
197
|
+
_aws_cdk_aws_ec2_alpha_ISubnetV2(p.subnet);
|
|
162
198
|
if (!visitedObjects.has(p.connectivityType))
|
|
163
199
|
_aws_cdk_aws_ec2_alpha_NatConnectivityType(p.connectivityType);
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
visitedObjects.delete(p);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function _aws_cdk_aws_ec2_alpha_NatGatewayProps(p) {
|
|
206
|
+
if (p == null)
|
|
207
|
+
return;
|
|
208
|
+
visitedObjects.add(p);
|
|
209
|
+
try {
|
|
164
210
|
if (!visitedObjects.has(p.vpc))
|
|
165
211
|
_aws_cdk_aws_ec2_alpha_IVpcV2(p.vpc);
|
|
212
|
+
if (!visitedObjects.has(p.subnet))
|
|
213
|
+
_aws_cdk_aws_ec2_alpha_ISubnetV2(p.subnet);
|
|
214
|
+
if (!visitedObjects.has(p.connectivityType))
|
|
215
|
+
_aws_cdk_aws_ec2_alpha_NatConnectivityType(p.connectivityType);
|
|
166
216
|
}
|
|
167
217
|
finally {
|
|
168
218
|
visitedObjects.delete(p);
|
|
@@ -172,7 +222,7 @@ function _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGateway(p) {
|
|
|
172
222
|
}
|
|
173
223
|
function _aws_cdk_aws_ec2_alpha_InternetGateway(p) {
|
|
174
224
|
}
|
|
175
|
-
function
|
|
225
|
+
function _aws_cdk_aws_ec2_alpha_VPNGatewayV2(p) {
|
|
176
226
|
}
|
|
177
227
|
function _aws_cdk_aws_ec2_alpha_NatGateway(p) {
|
|
178
228
|
}
|
|
@@ -256,4 +306,4 @@ class DeprecationError extends Error {
|
|
|
256
306
|
});
|
|
257
307
|
}
|
|
258
308
|
}
|
|
259
|
-
module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_ec2_alpha_SecondaryAddressProps, _aws_cdk_aws_ec2_alpha_IpAddresses, _aws_cdk_aws_ec2_alpha_VpcCidrOptions, _aws_cdk_aws_ec2_alpha_IIpAddresses, _aws_cdk_aws_ec2_alpha_VpcV2Props, _aws_cdk_aws_ec2_alpha_VpcV2, _aws_cdk_aws_ec2_alpha_AddressFamily, _aws_cdk_aws_ec2_alpha_IpamPoolPublicIpSource, _aws_cdk_aws_ec2_alpha_AwsServiceName, _aws_cdk_aws_ec2_alpha_IpamProps, _aws_cdk_aws_ec2_alpha_IpamScopeType, _aws_cdk_aws_ec2_alpha_PoolOptions, _aws_cdk_aws_ec2_alpha_IpamPoolCidrProvisioningOptions, _aws_cdk_aws_ec2_alpha_IIpamPool, _aws_cdk_aws_ec2_alpha_IpamScopeOptions, _aws_cdk_aws_ec2_alpha_IpamOptions, _aws_cdk_aws_ec2_alpha_IIpamScopeBase, _aws_cdk_aws_ec2_alpha_Ipam, _aws_cdk_aws_ec2_alpha_IVpcV2, _aws_cdk_aws_ec2_alpha_VpcV2Base, _aws_cdk_aws_ec2_alpha_IpCidr, _aws_cdk_aws_ec2_alpha_SubnetV2Props, _aws_cdk_aws_ec2_alpha_ISubnetV2, _aws_cdk_aws_ec2_alpha_SubnetV2, _aws_cdk_aws_ec2_alpha_NatConnectivityType, _aws_cdk_aws_ec2_alpha_IRouteTarget, _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGatewayProps, _aws_cdk_aws_ec2_alpha_InternetGatewayProps,
|
|
309
|
+
module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_ec2_alpha_SecondaryAddressProps, _aws_cdk_aws_ec2_alpha_IpAddresses, _aws_cdk_aws_ec2_alpha_VpcCidrOptions, _aws_cdk_aws_ec2_alpha_IIpAddresses, _aws_cdk_aws_ec2_alpha_VpcV2Props, _aws_cdk_aws_ec2_alpha_VpcV2, _aws_cdk_aws_ec2_alpha_AddressFamily, _aws_cdk_aws_ec2_alpha_IpamPoolPublicIpSource, _aws_cdk_aws_ec2_alpha_AwsServiceName, _aws_cdk_aws_ec2_alpha_IpamProps, _aws_cdk_aws_ec2_alpha_IpamScopeType, _aws_cdk_aws_ec2_alpha_PoolOptions, _aws_cdk_aws_ec2_alpha_IpamPoolCidrProvisioningOptions, _aws_cdk_aws_ec2_alpha_IIpamPool, _aws_cdk_aws_ec2_alpha_IpamScopeOptions, _aws_cdk_aws_ec2_alpha_IpamOptions, _aws_cdk_aws_ec2_alpha_IIpamScopeBase, _aws_cdk_aws_ec2_alpha_Ipam, _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGatewayOptions, _aws_cdk_aws_ec2_alpha_InternetGatewayOptions, _aws_cdk_aws_ec2_alpha_VPNGatewayV2Options, _aws_cdk_aws_ec2_alpha_IVpcV2, _aws_cdk_aws_ec2_alpha_VpcV2Base, _aws_cdk_aws_ec2_alpha_IpCidr, _aws_cdk_aws_ec2_alpha_SubnetV2Props, _aws_cdk_aws_ec2_alpha_ISubnetV2, _aws_cdk_aws_ec2_alpha_SubnetV2, _aws_cdk_aws_ec2_alpha_NatConnectivityType, _aws_cdk_aws_ec2_alpha_IRouteTarget, _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGatewayProps, _aws_cdk_aws_ec2_alpha_InternetGatewayProps, _aws_cdk_aws_ec2_alpha_VPNGatewayV2Props, _aws_cdk_aws_ec2_alpha_NatGatewayOptions, _aws_cdk_aws_ec2_alpha_NatGatewayProps, _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGateway, _aws_cdk_aws_ec2_alpha_InternetGateway, _aws_cdk_aws_ec2_alpha_VPNGatewayV2, _aws_cdk_aws_ec2_alpha_NatGateway, _aws_cdk_aws_ec2_alpha_RouteTargetProps, _aws_cdk_aws_ec2_alpha_RouteTargetType, _aws_cdk_aws_ec2_alpha_IRouteV2, _aws_cdk_aws_ec2_alpha_RouteProps, _aws_cdk_aws_ec2_alpha_Route, _aws_cdk_aws_ec2_alpha_RouteTableProps, _aws_cdk_aws_ec2_alpha_RouteTable };
|
package/README.md
CHANGED
|
@@ -27,10 +27,10 @@ To create a VPC with both IPv4 and IPv6 support:
|
|
|
27
27
|
```ts
|
|
28
28
|
|
|
29
29
|
const stack = new Stack();
|
|
30
|
-
new
|
|
31
|
-
primaryAddressBlock:
|
|
30
|
+
new VpcV2(this, 'Vpc', {
|
|
31
|
+
primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/24'),
|
|
32
32
|
secondaryAddressBlocks: [
|
|
33
|
-
|
|
33
|
+
IpAddresses.amazonProvidedIpv6({cidrBlockName: 'AmazonProvidedIpv6'}),
|
|
34
34
|
],
|
|
35
35
|
});
|
|
36
36
|
```
|
|
@@ -47,18 +47,18 @@ This new construct can be used to add subnets to a `VpcV2` instance:
|
|
|
47
47
|
```ts
|
|
48
48
|
|
|
49
49
|
const stack = new Stack();
|
|
50
|
-
const myVpc = new
|
|
50
|
+
const myVpc = new VpcV2(this, 'Vpc', {
|
|
51
51
|
secondaryAddressBlocks: [
|
|
52
|
-
|
|
52
|
+
IpAddresses.amazonProvidedIpv6({ cidrBlockName: 'AmazonProvidedIp'}),
|
|
53
53
|
],
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
new
|
|
56
|
+
new SubnetV2(this, 'subnetA', {
|
|
57
57
|
vpc: myVpc,
|
|
58
58
|
availabilityZone: 'us-east-1a',
|
|
59
|
-
ipv4CidrBlock: new
|
|
60
|
-
ipv6CidrBlock: new
|
|
61
|
-
subnetType:
|
|
59
|
+
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
60
|
+
ipv6CidrBlock: new IpCidr('2a05:d02c:25:4000::/60'),
|
|
61
|
+
subnetType: SubnetType.PRIVATE_ISOLATED,
|
|
62
62
|
})
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -77,28 +77,28 @@ const ipam = new Ipam(this, 'Ipam', {
|
|
|
77
77
|
operatingRegion: ['us-west-1']
|
|
78
78
|
});
|
|
79
79
|
const ipamPublicPool = ipam.publicScope.addPool('PublicPoolA', {
|
|
80
|
-
addressFamily:
|
|
80
|
+
addressFamily: AddressFamily.IP_V6,
|
|
81
81
|
awsService: AwsServiceName.EC2,
|
|
82
82
|
locale: 'us-west-1',
|
|
83
|
-
publicIpSource:
|
|
83
|
+
publicIpSource: IpamPoolPublicIpSource.AMAZON,
|
|
84
84
|
});
|
|
85
85
|
ipamPublicPool.provisionCidr('PublicPoolACidrA', { netmaskLength: 52 } );
|
|
86
86
|
|
|
87
87
|
const ipamPrivatePool = ipam.privateScope.addPool('PrivatePoolA', {
|
|
88
|
-
addressFamily:
|
|
88
|
+
addressFamily: AddressFamily.IP_V4,
|
|
89
89
|
});
|
|
90
90
|
ipamPrivatePool.provisionCidr('PrivatePoolACidrA', { netmaskLength: 8 } );
|
|
91
91
|
|
|
92
|
-
new
|
|
93
|
-
primaryAddressBlock:
|
|
92
|
+
new VpcV2(this, 'Vpc', {
|
|
93
|
+
primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/24'),
|
|
94
94
|
secondaryAddressBlocks: [
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
IpAddresses.amazonProvidedIpv6({ cidrBlockName: 'AmazonIpv6' }),
|
|
96
|
+
IpAddresses.ipv6Ipam({
|
|
97
97
|
ipamPool: ipamPublicPool,
|
|
98
98
|
netmaskLength: 52,
|
|
99
99
|
cidrBlockName: 'ipv6Ipam',
|
|
100
100
|
}),
|
|
101
|
-
|
|
101
|
+
IpAddresses.ipv4Ipam({
|
|
102
102
|
ipamPool: ipamPrivatePool,
|
|
103
103
|
netmaskLength: 8,
|
|
104
104
|
cidrBlockName: 'ipv4Ipam',
|
|
@@ -116,64 +116,88 @@ Since `VpcV2` does not create subnets automatically, users have full control ove
|
|
|
116
116
|
|
|
117
117
|
```ts
|
|
118
118
|
|
|
119
|
-
const myVpc = new
|
|
120
|
-
const routeTable = new
|
|
119
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
120
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
121
121
|
vpc: myVpc,
|
|
122
122
|
});
|
|
123
|
-
const subnet = new
|
|
123
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
124
124
|
vpc: myVpc,
|
|
125
125
|
routeTable,
|
|
126
126
|
availabilityZone: 'eu-west-2a',
|
|
127
127
|
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
128
|
-
subnetType:
|
|
128
|
+
subnetType: SubnetType.PRIVATE_ISOLATED,
|
|
129
129
|
});
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
`
|
|
132
|
+
`Routes` can be created to link subnets to various different AWS services via gateways and endpoints. Each unique route target has its own dedicated construct that can be routed to a given subnet via the `Route` construct. An example using the `InternetGateway` construct can be seen below:
|
|
133
133
|
|
|
134
134
|
```ts
|
|
135
135
|
const stack = new Stack();
|
|
136
|
-
const myVpc = new
|
|
137
|
-
const routeTable = new
|
|
136
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
137
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
138
138
|
vpc: myVpc,
|
|
139
139
|
});
|
|
140
|
-
const subnet = new
|
|
140
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
141
141
|
vpc: myVpc,
|
|
142
142
|
availabilityZone: 'eu-west-2a',
|
|
143
143
|
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
144
|
-
subnetType:
|
|
144
|
+
subnetType: SubnetType.PRIVATE_ISOLATED });
|
|
145
145
|
|
|
146
|
-
const igw = new
|
|
146
|
+
const igw = new InternetGateway(this, 'IGW', {
|
|
147
147
|
vpc: myVpc,
|
|
148
148
|
});
|
|
149
|
-
new
|
|
149
|
+
new Route(this, 'IgwRoute', {
|
|
150
150
|
routeTable,
|
|
151
151
|
destination: '0.0.0.0/0',
|
|
152
152
|
target: { gateway: igw },
|
|
153
153
|
});
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
+
Alternatively, `Routes` can also be created via method `addRoute` in the `RouteTable` class. An example using the `EgressOnlyInternetGateway` construct can be seen below:
|
|
157
|
+
Note: `EgressOnlyInternetGateway` can only be used to set up outbound IPv6 routing.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
|
|
161
|
+
const stack = new Stack();
|
|
162
|
+
const myVpc = new VpcV2(this, 'Vpc',{
|
|
163
|
+
primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
|
|
164
|
+
secondaryAddressBlocks: [IpAddresses.amazonProvidedIpv6({
|
|
165
|
+
cidrBlockName: 'AmazonProvided',
|
|
166
|
+
})]
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const eigw = new EgressOnlyInternetGateway(this, 'EIGW', {
|
|
170
|
+
vpc: myVpc,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
174
|
+
vpc: myVpc,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
routeTable.addRoute('EIGW', '::/0', { gateway: eigw });
|
|
178
|
+
```
|
|
179
|
+
|
|
156
180
|
Other route targets may require a deeper set of parameters to set up properly. For instance, the example below illustrates how to set up a `NatGateway`:
|
|
157
181
|
|
|
158
182
|
```ts
|
|
159
183
|
|
|
160
|
-
const myVpc = new
|
|
161
|
-
const routeTable = new
|
|
184
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
185
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
162
186
|
vpc: myVpc,
|
|
163
187
|
});
|
|
164
|
-
const subnet = new
|
|
188
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
165
189
|
vpc: myVpc,
|
|
166
190
|
availabilityZone: 'eu-west-2a',
|
|
167
191
|
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
168
|
-
subnetType:
|
|
192
|
+
subnetType: SubnetType.PRIVATE_ISOLATED });
|
|
169
193
|
|
|
170
|
-
const natgw = new
|
|
194
|
+
const natgw = new NatGateway(this, 'NatGW', {
|
|
171
195
|
subnet: subnet,
|
|
172
196
|
vpc: myVpc,
|
|
173
197
|
connectivityType: NatConnectivityType.PRIVATE,
|
|
174
198
|
privateIpAddress: '10.0.0.42',
|
|
175
199
|
});
|
|
176
|
-
new
|
|
200
|
+
new Route(this, 'NatGwRoute', {
|
|
177
201
|
routeTable,
|
|
178
202
|
destination: '0.0.0.0/0',
|
|
179
203
|
target: { gateway: natgw },
|
|
@@ -184,24 +208,161 @@ It is also possible to set up endpoints connecting other AWS services. For insta
|
|
|
184
208
|
|
|
185
209
|
```ts
|
|
186
210
|
|
|
187
|
-
const
|
|
188
|
-
const
|
|
211
|
+
const stack = new Stack();
|
|
212
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
213
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
189
214
|
vpc: myVpc,
|
|
190
215
|
});
|
|
191
|
-
const subnet = new
|
|
216
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
192
217
|
vpc: myVpc,
|
|
193
218
|
availabilityZone: 'eu-west-2a',
|
|
194
219
|
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
195
|
-
subnetType:
|
|
220
|
+
subnetType: SubnetType.PRIVATE });
|
|
196
221
|
|
|
197
222
|
const dynamoEndpoint = new ec2.GatewayVpcEndpoint(this, 'DynamoEndpoint', {
|
|
198
223
|
service: ec2.GatewayVpcEndpointAwsService.DYNAMODB,
|
|
199
224
|
vpc: myVpc,
|
|
200
225
|
subnets: [subnet],
|
|
201
226
|
});
|
|
202
|
-
new
|
|
227
|
+
new Route(this, 'DynamoDBRoute', {
|
|
203
228
|
routeTable,
|
|
204
229
|
destination: '0.0.0.0/0',
|
|
205
230
|
target: { endpoint: dynamoEndpoint },
|
|
206
231
|
});
|
|
207
232
|
```
|
|
233
|
+
|
|
234
|
+
## Adding Egress-Only Internet Gateway to VPC
|
|
235
|
+
|
|
236
|
+
An egress-only internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows outbound communication over IPv6 from instances in your VPC to the internet, and prevents the internet from initiating an IPv6 connection with your instances.
|
|
237
|
+
|
|
238
|
+
For more information see [Enable outbound IPv6 traffic using an egress-only internet gateway](https://docs.aws.amazon.com/vpc/latest/userguide/egress-only-internet-gateway.html).
|
|
239
|
+
|
|
240
|
+
VpcV2 supports adding an egress only internet gateway to VPC using the `addEgressOnlyInternetGateway` method.
|
|
241
|
+
|
|
242
|
+
By default, this method sets up a route to all outbound IPv6 address ranges, unless a specific destination is provided by the user. It can only be configured for IPv6-enabled VPCs.
|
|
243
|
+
The `Subnets` parameter accepts a `SubnetFilter`, which can be based on a `SubnetType` in VpcV2. A new route will be added to the route tables of all subnets that match this filter.
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
|
|
247
|
+
const stack = new Stack();
|
|
248
|
+
const myVpc = new VpcV2(this, 'Vpc',{
|
|
249
|
+
primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
|
|
250
|
+
secondaryAddressBlocks: [IpAddresses.amazonProvidedIpv6({
|
|
251
|
+
cidrBlockName: 'AmazonProvided',
|
|
252
|
+
})]
|
|
253
|
+
});
|
|
254
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
255
|
+
vpc: myVpc,
|
|
256
|
+
});
|
|
257
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
258
|
+
vpc: myVpc,
|
|
259
|
+
availabilityZone: 'eu-west-2a',
|
|
260
|
+
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
261
|
+
ipv6CidrBlock: new IpCidr('2001:db8:1::/64'),
|
|
262
|
+
subnetType: SubnetType.PRIVATE });
|
|
263
|
+
|
|
264
|
+
myVpc.addEgressOnlyInternetGateway({
|
|
265
|
+
subnets: [{subnetType: SubnetType.PRIVATE}],
|
|
266
|
+
destination: '::/60',
|
|
267
|
+
})
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Adding NATGateway to the VPC
|
|
271
|
+
|
|
272
|
+
A NAT gateway is a Network Address Translation (NAT) service.You can use a NAT gateway so that instances in a private subnet can connect to services outside your VPC but external services cannot initiate a connection with those instances.
|
|
273
|
+
|
|
274
|
+
For more information, see [NAT gateway basics](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html).
|
|
275
|
+
|
|
276
|
+
When you create a NAT gateway, you specify one of the following connectivity types:
|
|
277
|
+
|
|
278
|
+
**Public – (Default)**: Instances in private subnets can connect to the internet through a public NAT gateway, but cannot receive unsolicited inbound connections from the internet
|
|
279
|
+
|
|
280
|
+
**Private**: Instances in private subnets can connect to other VPCs or your on-premises network through a private NAT gateway.
|
|
281
|
+
|
|
282
|
+
To define the NAT gateway connectivity type as `ConnectivityType.Public`, you need to ensure that there is an IGW(Internet Gateway) attached to the subnet's VPC.
|
|
283
|
+
Since a NATGW is associated with a particular subnet, providing `subnet` field in the input props is mandatory.
|
|
284
|
+
|
|
285
|
+
Additionally, you can set up a route in any route table with the target set to the NAT Gateway. The function `addNatGateway` returns a `NATGateway` object that you can reference later.
|
|
286
|
+
|
|
287
|
+
The code example below provides the definition for adding a NAT gateway to your subnet:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
|
|
291
|
+
const stack = new Stack();
|
|
292
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
293
|
+
const routeTable = new RouteTable(this, 'RouteTable', {
|
|
294
|
+
vpc: myVpc,
|
|
295
|
+
});
|
|
296
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
297
|
+
vpc: myVpc,
|
|
298
|
+
availabilityZone: 'eu-west-2a',
|
|
299
|
+
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
300
|
+
subnetType: SubnetType.PUBLIC });
|
|
301
|
+
|
|
302
|
+
myVpc.addInternetGateway();
|
|
303
|
+
myVpc.addNatGateway({
|
|
304
|
+
subnet: subnet,
|
|
305
|
+
connectivityType: NatConnectivityType.PUBLIC,
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Enable VPNGateway for the VPC
|
|
310
|
+
|
|
311
|
+
A virtual private gateway is the endpoint on the VPC side of your VPN connection.
|
|
312
|
+
|
|
313
|
+
For more information, see [What is AWS Site-to-Site VPN?](https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html).
|
|
314
|
+
|
|
315
|
+
VPN route propagation is a feature in Amazon Web Services (AWS) that automatically updates route tables in your Virtual Private Cloud (VPC) with routes learned from a VPN connection.
|
|
316
|
+
|
|
317
|
+
To enable VPN route propogation, use the `vpnRoutePropagation` property to specify the subnets as an input to the function. VPN route propagation will then be enabled for each subnet with the corresponding route table IDs.
|
|
318
|
+
|
|
319
|
+
Additionally, you can set up a route in any route table with the target set to the VPN Gateway. The function `enableVpnGatewayV2` returns a `VPNGatewayV2` object that you can reference later.
|
|
320
|
+
|
|
321
|
+
The code example below provides the definition for setting up a VPN gateway with `vpnRoutePropogation` enabled:
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
|
|
325
|
+
const stack = new Stack();
|
|
326
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
327
|
+
const vpnGateway = myVpc.enableVpnGatewayV2({
|
|
328
|
+
vpnRoutePropagation: [{ subnetType: SubnetType.PUBLIC }],
|
|
329
|
+
type: VpnConnectionType.IPSEC_1,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const routeTable = new RouteTable(stack, 'routeTable', {
|
|
333
|
+
vpc: myVpc
|
|
334
|
+
} );
|
|
335
|
+
|
|
336
|
+
new Route(stack, 'route', {
|
|
337
|
+
destination: '172.31.0.0/24',
|
|
338
|
+
target: { gateway: vpnGateway },
|
|
339
|
+
routeTable: routeTable,
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Adding InternetGateway to the VPC
|
|
344
|
+
|
|
345
|
+
An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet. It supports both IPv4 and IPv6 traffic.
|
|
346
|
+
|
|
347
|
+
For more information, see [Enable VPC internet access using internet gateways](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-igw-internet-access.html).
|
|
348
|
+
|
|
349
|
+
You can add an internet gateway to a VPC using `addInternetGateway` method. By default, this method creates a route in all Public Subnets with outbound destination set to `0.0.0.0` for IPv4 and `::0` for IPv6 enabled VPC.
|
|
350
|
+
Instead of using the default settings, you can configure a custom destinatation range by providing an optional input `destination` to the method.
|
|
351
|
+
|
|
352
|
+
The code example below shows how to add an internet gateway with a custom outbound destination IP range:
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
|
|
356
|
+
const stack = new Stack();
|
|
357
|
+
const myVpc = new VpcV2(this, 'Vpc');
|
|
358
|
+
|
|
359
|
+
const subnet = new SubnetV2(this, 'Subnet', {
|
|
360
|
+
vpc: myVpc,
|
|
361
|
+
availabilityZone: 'eu-west-2a',
|
|
362
|
+
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
|
|
363
|
+
subnetType: SubnetType.PUBLIC });
|
|
364
|
+
|
|
365
|
+
myVpc.addInternetGateway({
|
|
366
|
+
ipv4Destination: '192.168.0.0/16',
|
|
367
|
+
});
|
|
368
|
+
```
|
package/awslint.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"exclude": [
|
|
3
3
|
"from-method:@aws-cdk/aws-ec2-alpha.VpcV2",
|
|
4
4
|
"attribute-tag:@aws-cdk/aws-ec2-alpha.RouteTable.routeTableId",
|
|
5
|
-
"from-method:@aws-cdk/aws-ec2-alpha.SubnetV2"
|
|
5
|
+
"from-method:@aws-cdk/aws-ec2-alpha.SubnetV2",
|
|
6
|
+
"from-method:@aws-cdk/aws-ec2-alpha.Route"
|
|
6
7
|
]
|
|
7
8
|
}
|
package/lib/ipam.d.ts
CHANGED
|
@@ -52,12 +52,14 @@ export interface IpamProps {
|
|
|
52
52
|
* Operating Regions are AWS Regions where the IPAM is allowed to manage IP address CIDRs
|
|
53
53
|
* For more information about operating Regions, see [Create an IPAM](https://docs.aws.amazon.com//vpc/latest/ipam/create-ipam.html) in the *Amazon VPC IPAM User Guide* .
|
|
54
54
|
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipam.html#cfn-ec2-ipam-operatingregions
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
|
+
* @default - Stack.region if defined in the stack
|
|
56
57
|
*/
|
|
57
58
|
readonly operatingRegion?: string[];
|
|
58
59
|
/**
|
|
59
60
|
* Name of IPAM that can be used for tagging resource
|
|
60
|
-
*
|
|
61
|
+
*
|
|
62
|
+
* @default - If no name provided, no tags will be added to the IPAM
|
|
61
63
|
*/
|
|
62
64
|
readonly ipamName?: string;
|
|
63
65
|
}
|
|
@@ -86,6 +88,7 @@ export interface PoolOptions {
|
|
|
86
88
|
readonly addressFamily: AddressFamily;
|
|
87
89
|
/**
|
|
88
90
|
* Information about the CIDRs provisioned to the pool.
|
|
91
|
+
*
|
|
89
92
|
* @default - No CIDRs are provisioned
|
|
90
93
|
*/
|
|
91
94
|
readonly ipv4ProvisionedCidrs?: string[];
|
|
@@ -95,13 +98,15 @@ export interface PoolOptions {
|
|
|
95
98
|
* You can only allocate a CIDR for a VPC, for example, from an IPAM pool that shares a locale with the VPC’s Region.
|
|
96
99
|
* Note that once you choose a Locale for a pool, you cannot modify it. If you choose an AWS Region for locale that has not been configured as an operating Region for the IPAM, you'll get an error.
|
|
97
100
|
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html#cfn-ec2-ipampool-locale
|
|
98
|
-
*
|
|
101
|
+
*
|
|
102
|
+
* @default - Current operating region of IPAM
|
|
99
103
|
*/
|
|
100
104
|
readonly locale?: string;
|
|
101
105
|
/**
|
|
102
106
|
* The IP address source for pools in the public scope.
|
|
103
107
|
* Only used for IPv6 address
|
|
104
108
|
* Only allowed values to this are 'byoip' or 'amazon'
|
|
109
|
+
*
|
|
105
110
|
* @default amazon
|
|
106
111
|
*/
|
|
107
112
|
readonly publicIpSource?: IpamPoolPublicIpSource;
|
|
@@ -112,7 +117,7 @@ export interface PoolOptions {
|
|
|
112
117
|
*
|
|
113
118
|
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html#cfn-ec2-ipampool-awsservice
|
|
114
119
|
*
|
|
115
|
-
* @default -
|
|
120
|
+
* @default - required in case of an IPv6, throws an error if not provided.
|
|
116
121
|
*/
|
|
117
122
|
readonly awsService?: AwsServiceName;
|
|
118
123
|
}
|
|
@@ -124,12 +129,14 @@ export interface PoolOptions {
|
|
|
124
129
|
export interface IpamPoolCidrProvisioningOptions {
|
|
125
130
|
/**
|
|
126
131
|
* Ipv6 Netmask length for the CIDR
|
|
127
|
-
*
|
|
132
|
+
*
|
|
133
|
+
* @default - pool provisioned without netmask length, need cidr range in this case
|
|
128
134
|
*/
|
|
129
135
|
readonly netmaskLength?: number;
|
|
130
136
|
/**
|
|
131
137
|
* Ipv6 CIDR block for the IPAM pool
|
|
132
|
-
*
|
|
138
|
+
*
|
|
139
|
+
* @default - pool provisioned without netmask length, need netmask length in this case
|
|
133
140
|
*/
|
|
134
141
|
readonly cidr?: string;
|
|
135
142
|
}
|
|
@@ -157,7 +164,8 @@ export interface IIpamPool {
|
|
|
157
164
|
export interface IpamScopeOptions {
|
|
158
165
|
/**
|
|
159
166
|
* IPAM scope name that will be used for tagging
|
|
160
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* @default - no tags will be added to the scope
|
|
161
169
|
*/
|
|
162
170
|
readonly ipamScopeName?: string;
|
|
163
171
|
}
|
|
@@ -171,14 +179,14 @@ export interface IpamOptions {
|
|
|
171
179
|
* CIDR Mask for Vpc
|
|
172
180
|
* Only required when using AWS Ipam
|
|
173
181
|
*
|
|
174
|
-
* @default -
|
|
182
|
+
* @default - no netmask length for IPAM attached to VPC secondary address
|
|
175
183
|
*/
|
|
176
184
|
readonly netmaskLength?: number;
|
|
177
185
|
/**
|
|
178
186
|
* Ipv4 or an Ipv6 IPAM pool
|
|
179
187
|
* Only required when using AWS Ipam
|
|
180
188
|
*
|
|
181
|
-
* @default -
|
|
189
|
+
* @default - no pool attached to VPC secondary address
|
|
182
190
|
*/
|
|
183
191
|
readonly ipamPool?: IIpamPool;
|
|
184
192
|
/**
|