@aws-cdk/aws-ec2-alpha 2.177.0-alpha.0 → 2.178.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.
Binary file
package/.warnings.jsii.js CHANGED
@@ -127,6 +127,18 @@ function _aws_cdk_aws_ec2_alpha_EgressOnlyInternetGatewayOptions(p) {
127
127
  }
128
128
  }
129
129
  function _aws_cdk_aws_ec2_alpha_InternetGatewayOptions(p) {
130
+ if (p == null)
131
+ return;
132
+ visitedObjects.add(p);
133
+ try {
134
+ if (p.subnets != null)
135
+ for (const o of p.subnets)
136
+ if (!visitedObjects.has(o))
137
+ require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_SubnetSelection(o);
138
+ }
139
+ finally {
140
+ visitedObjects.delete(p);
141
+ }
130
142
  }
131
143
  function _aws_cdk_aws_ec2_alpha_VPNGatewayV2Options(p) {
132
144
  if (p == null)
@@ -324,6 +336,158 @@ function _aws_cdk_aws_ec2_alpha_RouteTableProps(p) {
324
336
  }
325
337
  function _aws_cdk_aws_ec2_alpha_RouteTable(p) {
326
338
  }
339
+ function _aws_cdk_aws_ec2_alpha_ITransitGateway(p) {
340
+ }
341
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayProps(p) {
342
+ }
343
+ function _aws_cdk_aws_ec2_alpha_TransitGateway(p) {
344
+ }
345
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayRoute(p) {
346
+ }
347
+ function _aws_cdk_aws_ec2_alpha_BaseTransitGatewayRouteProps(p) {
348
+ if (p == null)
349
+ return;
350
+ visitedObjects.add(p);
351
+ try {
352
+ if (!visitedObjects.has(p.transitGatewayRouteTable))
353
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.transitGatewayRouteTable);
354
+ }
355
+ finally {
356
+ visitedObjects.delete(p);
357
+ }
358
+ }
359
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteProps(p) {
360
+ if (p == null)
361
+ return;
362
+ visitedObjects.add(p);
363
+ try {
364
+ if (!visitedObjects.has(p.transitGatewayAttachment))
365
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayAttachment(p.transitGatewayAttachment);
366
+ if (!visitedObjects.has(p.transitGatewayRouteTable))
367
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.transitGatewayRouteTable);
368
+ }
369
+ finally {
370
+ visitedObjects.delete(p);
371
+ }
372
+ }
373
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayBlackholeRouteProps(p) {
374
+ if (p == null)
375
+ return;
376
+ visitedObjects.add(p);
377
+ try {
378
+ if (!visitedObjects.has(p.transitGatewayRouteTable))
379
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.transitGatewayRouteTable);
380
+ }
381
+ finally {
382
+ visitedObjects.delete(p);
383
+ }
384
+ }
385
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRoute(p) {
386
+ }
387
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayBlackholeRoute(p) {
388
+ }
389
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p) {
390
+ }
391
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableProps(p) {
392
+ if (p == null)
393
+ return;
394
+ visitedObjects.add(p);
395
+ try {
396
+ if (!visitedObjects.has(p.transitGateway))
397
+ _aws_cdk_aws_ec2_alpha_ITransitGateway(p.transitGateway);
398
+ }
399
+ finally {
400
+ visitedObjects.delete(p);
401
+ }
402
+ }
403
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTable(p) {
404
+ }
405
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayAttachment(p) {
406
+ }
407
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachmentOptions(p) {
408
+ }
409
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachment(p) {
410
+ }
411
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayVpcAttachmentProps(p) {
412
+ if (p == null)
413
+ return;
414
+ visitedObjects.add(p);
415
+ try {
416
+ if (p.subnets != null)
417
+ for (const o of p.subnets)
418
+ if (!visitedObjects.has(o))
419
+ require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_ISubnet(o);
420
+ if (!visitedObjects.has(p.transitGateway))
421
+ _aws_cdk_aws_ec2_alpha_ITransitGateway(p.transitGateway);
422
+ if (!visitedObjects.has(p.vpcAttachmentOptions))
423
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachmentOptions(p.vpcAttachmentOptions);
424
+ }
425
+ finally {
426
+ visitedObjects.delete(p);
427
+ }
428
+ }
429
+ function _aws_cdk_aws_ec2_alpha_AttachVpcOptions(p) {
430
+ if (p == null)
431
+ return;
432
+ visitedObjects.add(p);
433
+ try {
434
+ if (p.subnets != null)
435
+ for (const o of p.subnets)
436
+ if (!visitedObjects.has(o))
437
+ require("aws-cdk-lib/.warnings.jsii.js").aws_cdk_lib_aws_ec2_ISubnet(o);
438
+ if (!visitedObjects.has(p.associationRouteTable))
439
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.associationRouteTable);
440
+ if (p.propagationRouteTables != null)
441
+ for (const o of p.propagationRouteTables)
442
+ if (!visitedObjects.has(o))
443
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(o);
444
+ if (!visitedObjects.has(p.vpcAttachmentOptions))
445
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachmentOptions(p.vpcAttachmentOptions);
446
+ }
447
+ finally {
448
+ visitedObjects.delete(p);
449
+ }
450
+ }
451
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayVpcAttachment(p) {
452
+ }
453
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayAssociation(p) {
454
+ }
455
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTableAssociation(p) {
456
+ }
457
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableAssociationProps(p) {
458
+ if (p == null)
459
+ return;
460
+ visitedObjects.add(p);
461
+ try {
462
+ if (!visitedObjects.has(p.transitGatewayRouteTable))
463
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.transitGatewayRouteTable);
464
+ if (!visitedObjects.has(p.transitGatewayVpcAttachment))
465
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayAttachment(p.transitGatewayVpcAttachment);
466
+ }
467
+ finally {
468
+ visitedObjects.delete(p);
469
+ }
470
+ }
471
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableAssociation(p) {
472
+ }
473
+ function _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTablePropagation(p) {
474
+ }
475
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTablePropagationProps(p) {
476
+ if (p == null)
477
+ return;
478
+ visitedObjects.add(p);
479
+ try {
480
+ if (!visitedObjects.has(p.transitGatewayRouteTable))
481
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable(p.transitGatewayRouteTable);
482
+ if (!visitedObjects.has(p.transitGatewayVpcAttachment))
483
+ _aws_cdk_aws_ec2_alpha_ITransitGatewayAttachment(p.transitGatewayVpcAttachment);
484
+ }
485
+ finally {
486
+ visitedObjects.delete(p);
487
+ }
488
+ }
489
+ function _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTablePropagation(p) {
490
+ }
327
491
  function print(name, deprecationMessage) {
328
492
  const deprecated = process.env.JSII_DEPRECATED;
329
493
  const deprecationMode = ["warn", "fail", "quiet"].includes(deprecated) ? deprecated : "warn";
@@ -360,4 +524,4 @@ class DeprecationError extends Error {
360
524
  });
361
525
  }
362
526
  }
363
- module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_ec2_alpha_SecondaryAddressProps, _aws_cdk_aws_ec2_alpha_Ipv6PoolSecondaryAddressProps, _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_VpcV2Attributes, _aws_cdk_aws_ec2_alpha_VpcV2, _aws_cdk_aws_ec2_alpha_IVPCCidrBlock, _aws_cdk_aws_ec2_alpha_VPCCidrBlockattributes, _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_SubnetV2Attributes, _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_VPCPeeringConnectionOptions, _aws_cdk_aws_ec2_alpha_VPCPeeringConnectionProps, _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_VPCPeeringConnection, _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 };
527
+ module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_ec2_alpha_SecondaryAddressProps, _aws_cdk_aws_ec2_alpha_Ipv6PoolSecondaryAddressProps, _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_VpcV2Attributes, _aws_cdk_aws_ec2_alpha_VpcV2, _aws_cdk_aws_ec2_alpha_IVPCCidrBlock, _aws_cdk_aws_ec2_alpha_VPCCidrBlockattributes, _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_SubnetV2Attributes, _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_VPCPeeringConnectionOptions, _aws_cdk_aws_ec2_alpha_VPCPeeringConnectionProps, _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_VPCPeeringConnection, _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, _aws_cdk_aws_ec2_alpha_ITransitGateway, _aws_cdk_aws_ec2_alpha_TransitGatewayProps, _aws_cdk_aws_ec2_alpha_TransitGateway, _aws_cdk_aws_ec2_alpha_ITransitGatewayRoute, _aws_cdk_aws_ec2_alpha_BaseTransitGatewayRouteProps, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteProps, _aws_cdk_aws_ec2_alpha_TransitGatewayBlackholeRouteProps, _aws_cdk_aws_ec2_alpha_TransitGatewayRoute, _aws_cdk_aws_ec2_alpha_TransitGatewayBlackholeRoute, _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTable, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableProps, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTable, _aws_cdk_aws_ec2_alpha_ITransitGatewayAttachment, _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachmentOptions, _aws_cdk_aws_ec2_alpha_ITransitGatewayVpcAttachment, _aws_cdk_aws_ec2_alpha_TransitGatewayVpcAttachmentProps, _aws_cdk_aws_ec2_alpha_AttachVpcOptions, _aws_cdk_aws_ec2_alpha_TransitGatewayVpcAttachment, _aws_cdk_aws_ec2_alpha_ITransitGatewayAssociation, _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTableAssociation, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableAssociationProps, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTableAssociation, _aws_cdk_aws_ec2_alpha_ITransitGatewayRouteTablePropagation, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTablePropagationProps, _aws_cdk_aws_ec2_alpha_TransitGatewayRouteTablePropagation };
package/README.md CHANGED
@@ -3,29 +3,30 @@
3
3
 
4
4
  ---
5
5
 
6
- ![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
6
+ ![cdk-constructs: Developer Preview](https://img.shields.io/badge/cdk--constructs-developer--preview-informational.svg?style=for-the-badge)
7
7
 
8
- > The APIs of higher level constructs in this module are experimental and under active development.
9
- > They are subject to non-backward compatible changes or removal in any future version. These are
10
- > not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
11
- > announced in the release notes. This means that while you may use them, you may need to update
12
- > your source code when upgrading to a newer version of this package.
8
+ > The APIs of higher level constructs in this module are in **developer preview** before they
9
+ > become stable. We will only make breaking changes to address unforeseen API issues. Therefore,
10
+ > these APIs are not subject to [Semantic Versioning](https://semver.org/), and breaking changes
11
+ > will be announced in release notes. This means that while you may use them, you may need to
12
+ > update your source code when upgrading to a newer version of this package.
13
13
 
14
14
  ---
15
15
 
16
16
  <!--END STABILITY BANNER-->
17
17
 
18
-
19
18
  ## VpcV2
20
19
 
21
20
  `VpcV2` is a re-write of the [`ec2.Vpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html) construct. This new construct enables higher level of customization
22
21
  on the VPC being created. `VpcV2` implements the existing [`IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html), therefore,
23
22
  `VpcV2` is compatible with other constructs that accepts `IVpc` (e.g. [`ApplicationLoadBalancer`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationLoadBalancer.html#construct-props)).
24
23
 
25
- To create a VPC with both IPv4 and IPv6 support:
24
+ `VpcV2` supports the addition of both primary and secondary addresses. The primary address must be an IPv4 address, which can be specified as a CIDR string or assigned from an IPAM pool. Secondary addresses can be either IPv4 or IPv6.
25
+ By default, `VpcV2` assigns `10.0.0.0/16` as the primary CIDR if no other CIDR is specified.
26
26
 
27
- ```ts
27
+ Below is an example of creating a VPC with both IPv4 and IPv6 support:
28
28
 
29
+ ```ts
29
30
  const stack = new Stack();
30
31
  new VpcV2(this, 'Vpc', {
31
32
  primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/24'),
@@ -41,9 +42,9 @@ new VpcV2(this, 'Vpc', {
41
42
 
42
43
  `SubnetV2` is a re-write of the [`ec2.Subnet`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Subnet.html) construct.
43
44
  This new construct can be used to add subnets to a `VpcV2` instance:
45
+ Note: When defining a subnet with `SubnetV2`, CDK automatically creates a new route table, unless a route table is explicitly provided as an input to the construct.
44
46
 
45
47
  ```ts
46
-
47
48
  const stack = new Stack();
48
49
  const myVpc = new VpcV2(this, 'Vpc', {
49
50
  secondaryAddressBlocks: [
@@ -60,17 +61,25 @@ new SubnetV2(this, 'subnetA', {
60
61
  })
61
62
  ```
62
63
 
64
+ Since `VpcV2` does not create subnets automatically, users have full control over IP addresses allocation across subnets.
65
+
63
66
  ## IP Addresses Management
64
67
 
65
- By default `VpcV2` uses `10.0.0.0/16` as the primary CIDR if none is defined.
66
- Additional CIDRs can be adding to the VPC via the `secondaryAddressBlocks` prop.
67
- The following example illustrates the different options of defining the address blocks:
68
+ Additional CIDRs can be added to the VPC via the `secondaryAddressBlocks` property.
69
+ The following example illustrates the options of defining these secondary address blocks using `IPAM`:
68
70
 
69
- ```ts
71
+ Note: There’s currently an issue with IPAM pool deletion that may affect the `cdk --destroy` command. This is because IPAM takes time to detect when the IP address pool has been deallocated after the VPC is deleted. The current workaround is to wait until the IP address is fully deallocated from the pool before retrying the deletion. Below command can be used to check allocations for a pool using CLI
72
+
73
+ ```shell
74
+ aws ec2 get-ipam-pool-allocations --ipam-pool-id <ipam-pool-id>
75
+ ```
70
76
 
77
+ Ref: https://docs.aws.amazon.com/cli/latest/reference/ec2/get-ipam-pool-allocations.html
78
+
79
+ ```ts
71
80
  const stack = new Stack();
72
81
  const ipam = new Ipam(this, 'Ipam', {
73
- operatingRegion: ['us-west-1']
82
+ operatingRegions: ['us-west-1']
74
83
  });
75
84
  const ipamPublicPool = ipam.publicScope.addPool('PublicPoolA', {
76
85
  addressFamily: AddressFamily.IP_V6,
@@ -103,8 +112,6 @@ new VpcV2(this, 'Vpc', {
103
112
  });
104
113
  ```
105
114
 
106
- Since `VpcV2` does not create subnets automatically, users have full control over IP addresses allocation across subnets.
107
-
108
115
  ### Bring your own IPv6 addresses (BYOIP)
109
116
 
110
117
  If you have your own IP address that you would like to use with EC2, you can set up an IPv6 pool via the AWS CLI, and use that pool ID in your application.
@@ -140,10 +147,10 @@ const myVpc = new VpcV2(this, 'Vpc', {
140
147
 
141
148
  ## Routing
142
149
 
143
- `RouteTable` is a new construct that allows for route tables to be customized in a variety of ways. For instance, the following example shows how a custom route table can be created and appended to a subnet:
150
+ `RouteTable` is a new construct that allows for route tables to be customized in a variety of ways. Using this construct, a customized route table can be added to the subnets defined using `SubnetV2`.
151
+ For instance, the following example shows how a custom route table can be created and appended to a `SubnetV2`:
144
152
 
145
153
  ```ts
146
-
147
154
  const myVpc = new VpcV2(this, 'Vpc');
148
155
  const routeTable = new RouteTable(this, 'RouteTable', {
149
156
  vpc: myVpc,
@@ -185,7 +192,6 @@ Alternatively, `Routes` can also be created via method `addRoute` in the `RouteT
185
192
  Note: `EgressOnlyInternetGateway` can only be used to set up outbound IPv6 routing.
186
193
 
187
194
  ```ts
188
-
189
195
  const stack = new Stack();
190
196
  const myVpc = new VpcV2(this, 'Vpc',{
191
197
  primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
@@ -208,7 +214,6 @@ routeTable.addRoute('EIGW', '::/0', { gateway: eigw });
208
214
  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`:
209
215
 
210
216
  ```ts
211
-
212
217
  const myVpc = new VpcV2(this, 'Vpc');
213
218
  const routeTable = new RouteTable(this, 'RouteTable', {
214
219
  vpc: myVpc,
@@ -235,7 +240,6 @@ new Route(this, 'NatGwRoute', {
235
240
  It is also possible to set up endpoints connecting other AWS services. For instance, the example below illustrates the linking of a Dynamo DB endpoint via the existing `ec2.GatewayVpcEndpoint` construct as a route target:
236
241
 
237
242
  ```ts
238
-
239
243
  const stack = new Stack();
240
244
  const myVpc = new VpcV2(this, 'Vpc');
241
245
  const routeTable = new RouteTable(this, 'RouteTable', {
@@ -257,7 +261,6 @@ new Route(this, 'DynamoDBRoute', {
257
261
  destination: '0.0.0.0/0',
258
262
  target: { endpoint: dynamoEndpoint },
259
263
  });
260
-
261
264
  ```
262
265
 
263
266
  ## VPC Peering Connection
@@ -422,7 +425,6 @@ By default, this method sets up a route to all outbound IPv6 address ranges, unl
422
425
  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.
423
426
 
424
427
  ```ts
425
-
426
428
  const stack = new Stack();
427
429
  const myVpc = new VpcV2(this, 'Vpc',{
428
430
  primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
@@ -466,7 +468,6 @@ Additionally, you can set up a route in any route table with the target set to t
466
468
  The code example below provides the definition for adding a NAT gateway to your subnet:
467
469
 
468
470
  ```ts
469
-
470
471
  const stack = new Stack();
471
472
  const myVpc = new VpcV2(this, 'Vpc');
472
473
  const routeTable = new RouteTable(this, 'RouteTable', {
@@ -500,7 +501,6 @@ Additionally, you can set up a route in any route table with the target set to t
500
501
  The code example below provides the definition for setting up a VPN gateway with `vpnRoutePropagation` enabled:
501
502
 
502
503
  ```ts
503
-
504
504
  const stack = new Stack();
505
505
  const myVpc = new VpcV2(this, 'Vpc');
506
506
  const vpnGateway = myVpc.enableVpnGatewayV2({
@@ -527,11 +527,11 @@ For more information, see [Enable VPC internet access using internet gateways](h
527
527
 
528
528
  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.
529
529
  Instead of using the default settings, you can configure a custom destination range by providing an optional input `destination` to the method.
530
+ In addition to the custom IP range, you can also choose to filter subnets where default routes should be created.
530
531
 
531
532
  The code example below shows how to add an internet gateway with a custom outbound destination IP range:
532
533
 
533
534
  ```ts
534
-
535
535
  const stack = new Stack();
536
536
  const myVpc = new VpcV2(this, 'Vpc');
537
537
 
@@ -546,6 +546,34 @@ myVpc.addInternetGateway({
546
546
  });
547
547
  ```
548
548
 
549
+ The following code examples demonstrates how to add an internet gateway with a custom outbound destination IP range for specific subnets:
550
+
551
+ ```ts
552
+ const stack = new Stack();
553
+ const myVpc = new VpcV2(this, 'Vpc');
554
+
555
+ const mySubnet = new SubnetV2(this, 'Subnet', {
556
+ vpc: myVpc,
557
+ availabilityZone: 'eu-west-2a',
558
+ ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
559
+ subnetType: SubnetType.PUBLIC });
560
+
561
+ myVpc.addInternetGateway({
562
+ ipv4Destination: '192.168.0.0/16',
563
+ subnets: [mySubnet],
564
+ });
565
+ ```
566
+
567
+ ```ts
568
+ const stack = new Stack();
569
+ const myVpc = new VpcV2(this, 'Vpc');
570
+
571
+ myVpc.addInternetGateway({
572
+ ipv4Destination: '192.168.0.0/16',
573
+ subnets: [{subnetType: SubnetType.PRIVATE_WITH_EGRESS}],
574
+ });
575
+ ```
576
+
549
577
  ## Importing an existing VPC
550
578
 
551
579
  You can import an existing VPC and its subnets using the `VpcV2.fromVpcV2Attributes()` method or an individual subnet using `SubnetV2.fromSubnetV2Attributes()` method.
@@ -559,14 +587,12 @@ If you wish to add a new subnet to imported VPC, new subnet's IP range(IPv4) wil
559
587
  Here's an example of importing a VPC with only the required parameters
560
588
 
561
589
  ``` ts
562
-
563
590
  const stack = new Stack();
564
591
 
565
592
  const importedVpc = VpcV2.fromVpcV2Attributes(stack, 'ImportedVpc', {
566
593
  vpcId: 'mockVpcID',
567
594
  vpcCidrBlock: '10.0.0.0/16',
568
595
  });
569
-
570
596
  ```
571
597
 
572
598
  In case of cross account or cross region VPC, its recommended to provide region and ownerAccountId so that these values for the VPC can be used to populate correct arn value for the VPC. If a VPC region and account ID is not provided, then region and account configured in the stack will be used. Furthermore, these fields will be referenced later while setting up VPC peering connection, so its necessary to set these fields to a correct value.
@@ -574,7 +600,6 @@ In case of cross account or cross region VPC, its recommended to provide region
574
600
  Below is an example of importing a cross region and cross account VPC, VPC arn for this case would be 'arn:aws:ec2:us-west-2:123456789012:vpc/mockVpcID'
575
601
 
576
602
  ``` ts
577
-
578
603
  const stack = new Stack();
579
604
 
580
605
  //Importing a cross account or cross region VPC
@@ -584,7 +609,6 @@ const importedVpc = VpcV2.fromVpcV2Attributes(stack, 'ImportedVpc', {
584
609
  ownerAccountId: '123456789012',
585
610
  region: 'us-west-2',
586
611
  });
587
-
588
612
  ```
589
613
 
590
614
  Here's an example of how to import a VPC with multiple CIDR blocks, IPv6 support, and different subnet types:
@@ -599,7 +623,6 @@ In this example, we're importing a VPC with:
599
623
  - A public subnet in us-west-2b
600
624
 
601
625
  ```ts
602
-
603
626
  const stack = new Stack();
604
627
 
605
628
  const importedVpc = VpcV2.fromVpcV2Attributes(this, 'ImportedVPC', {
@@ -666,7 +689,6 @@ You can also import individual subnets using the `SubnetV2.fromSubnetV2Attribute
666
689
  Here's an example of how to import a subnet:
667
690
 
668
691
  ```ts
669
-
670
692
  SubnetV2.fromSubnetV2Attributes(this, 'ImportedSubnet', {
671
693
  subnetId: 'subnet-0123456789abcdef0',
672
694
  availabilityZone: 'us-west-2a',
@@ -685,7 +707,6 @@ By default, when a resource name is given to the construct, it automatically add
685
707
  For example, if the `vpcName` is set to `TestVpc`, the following code will add a tag to the VPC with `key: Name` and `value: TestVpc`.
686
708
 
687
709
  ```ts
688
-
689
710
  const vpc = new VpcV2(this, 'VPC-integ-test-tag', {
690
711
  primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
691
712
  enableDnsHostnames: true,
@@ -696,3 +717,191 @@ const vpc = new VpcV2(this, 'VPC-integ-test-tag', {
696
717
  // Add custom tags if needed
697
718
  Tags.of(vpc).add('Environment', 'Production');
698
719
  ```
720
+
721
+ ## Transit Gateway
722
+
723
+ The AWS Transit Gateway construct library allows you to create and configure Transit Gateway resources using AWS CDK.
724
+
725
+ See [AWS Transit Gateway Docs](docs.aws.amazon.com/vpc/latest/tgw/what-is-transit-gateway.html) for more info.
726
+
727
+ ### Overview
728
+
729
+ The Transit Gateway construct (`TransitGateway`) is the main entry point for creating and managing your Transit Gateway infrastructure. It provides methods to create route tables, attach VPCs, and configure cross-account access.
730
+
731
+ The Transit Gateway construct library provides four main constructs:
732
+
733
+ - `TransitGateway`: The central hub for your network connections
734
+ - `TransitGatewayRouteTable`: Manages routing between attached networks
735
+ - `TransitGatewayVpcAttachment`: Connects VPCs to the Transit Gateway
736
+ - `TransitGatewayRoute`: Defines routing rules within your Transit Gateway
737
+
738
+ ### Basic Usage
739
+
740
+ To create a minimal deployable `TransitGateway`:
741
+
742
+ ```ts
743
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
744
+ ```
745
+
746
+ ### Default Transit Gateway Route Table
747
+
748
+ By default, `TransitGateway` is created with a default `TransitGatewayRouteTable`, for which automatic Associations and automatic Propagations are enabled.
749
+
750
+ > Note: When you create a default Transit Gateway in AWS Console, a default Transit Gateway Route Table is automatically created by AWS. However, when using the CDK Transit Gateway L2 construct, the underlying L1 construct is configured with `defaultRouteTableAssociation` and `defaultRouteTablePropagation` explicitly disabled. This ensures that AWS does not create the default route table, allowing the CDK to define a custom default route table instead.
751
+ >
752
+ > As a result, in the AWS Console, the **Default association route table** and **Default propagation route table** settings will appear as disabled. Despite this, the CDK still provides automatic association and propagation functionality through its internal implementation, which can be controlled using the `defaultRouteTableAssociation` and `defaultRouteTablePropagation` properties within the CDK.
753
+
754
+
755
+ You can disable the automatic Association/Propagation on the default `TransitGatewayRouteTable` via the `TransitGateway` properties. This will still create a default route table for you:
756
+
757
+ ```ts
758
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway', {
759
+ defaultRouteTableAssociation: false,
760
+ defaultRouteTablePropagation: false,
761
+ });
762
+ ```
763
+
764
+ ### Transit Gateway Route Table Management
765
+
766
+ Add additional Transit Gateway Route Tables using the `addRouteTable()` method:
767
+
768
+ ```ts
769
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
770
+
771
+ const routeTable = transitGateway.addRouteTable('CustomRouteTable');
772
+ ```
773
+
774
+ ### Attaching VPCs to the Transit Gateway
775
+
776
+ Currently only VPC to Transit Gateway attachments are supported.
777
+
778
+ Create an attachment from a VPC to the Transit Gateway using the `attachVpc()` method:
779
+
780
+ ```ts
781
+ const myVpc = new VpcV2(this, 'Vpc');
782
+ const subnet1 = new SubnetV2(this, 'Subnet', {
783
+ vpc: myVpc,
784
+ availabilityZone: 'eu-west-2a',
785
+ ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
786
+ subnetType: SubnetType.PUBLIC
787
+ });
788
+
789
+ const subnet2 = new SubnetV2(this, 'Subnet', {
790
+ vpc: myVpc,
791
+ availabilityZone: 'eu-west-2a',
792
+ ipv4CidrBlock: new IpCidr('10.0.1.0/24'),
793
+ subnetType: SubnetType.PUBLIC
794
+ });
795
+
796
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
797
+
798
+ // Create a basic attachment
799
+ const attachment = transitGateway.attachVpc('VpcAttachment', {
800
+ vpc: myVpc,
801
+ subnets: [subnet1, subnet2]
802
+ });
803
+
804
+ // Create an attachment with optional parameters
805
+ const attachmentWithOptions = transitGateway.attachVpc('VpcAttachmentWithOptions', {
806
+ vpc: myVpc,
807
+ subnets: [subnet1],
808
+ vpcAttachmentOptions: {
809
+ dnsSupport: true,
810
+ applianceModeSupport: true,
811
+ ipv6Support: true,
812
+ securityGroupReferencingSupport: true,
813
+ }
814
+ });
815
+ ```
816
+
817
+ If you want to automatically associate and propagate routes with transit gateway route tables, you can pass the `associationRouteTable` and `propagationRouteTables` parameters. This will automatically create the necessary associations and propagations based on the provided route tables.
818
+
819
+ ```ts
820
+ const myVpc = new VpcV2(this, 'Vpc');
821
+ const subnet1 = new SubnetV2(this, 'Subnet', {
822
+ vpc: myVpc,
823
+ availabilityZone: 'eu-west-2a',
824
+ ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
825
+ subnetType: SubnetType.PUBLIC
826
+ });
827
+
828
+ const subnet2 = new SubnetV2(this, 'Subnet', {
829
+ vpc: myVpc,
830
+ availabilityZone: 'eu-west-2a',
831
+ ipv4CidrBlock: new IpCidr('10.0.1.0/24'),
832
+ subnetType: SubnetType.PUBLIC
833
+ });
834
+
835
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
836
+ const associationRouteTable = transitGateway.addRouteTable('AssociationRouteTable');
837
+ const propagationRouteTable1 = transitGateway.addRouteTable('PropagationRouteTable1');
838
+ const propagationRouteTable2 = transitGateway.addRouteTable('PropagationRouteTable2');
839
+
840
+ // Create an attachment with automatically created association + propagations
841
+ const attachmentWithRoutes = transitGateway.attachVpc('VpcAttachment', {
842
+ vpc: myVpc,
843
+ subnets: [subnet1, subnet2],
844
+ associationRouteTable: associationRouteTable,
845
+ propagationRouteTables: [propagationRouteTable1, propagationRouteTable2],
846
+ });
847
+ ```
848
+
849
+ In this example, the `associationRouteTable` is set to `associationRouteTable`, and `propagationRouteTables` is set to an array containing `propagationRouteTable1` and `propagationRouteTable2`. This triggers the automatic creation of route table associations and route propagations between the Transit Gateway and the specified route tables.
850
+
851
+ ### Adding static routes to the route table
852
+
853
+ Add static routes using either the `addRoute()` method to add an active route or `addBlackholeRoute()` to add a blackhole route:
854
+
855
+ ```ts
856
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
857
+ const routeTable = transitGateway.addRouteTable('CustomRouteTable');
858
+
859
+ const myVpc = new VpcV2(this, 'Vpc');
860
+ const subnet = new SubnetV2(this, 'Subnet', {
861
+ vpc: myVpc,
862
+ availabilityZone: 'eu-west-2a',
863
+ ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
864
+ subnetType: SubnetType.PUBLIC
865
+ });
866
+
867
+ const attachment = transitGateway.attachVpc('VpcAttachment', {
868
+ vpc: myVpc,
869
+ subnets: [subnet]
870
+ });
871
+
872
+ // Add a static route to direct traffic
873
+ routeTable.addRoute('StaticRoute', attachment, '10.0.0.0/16');
874
+
875
+ // Block unwanted traffic with a blackhole route
876
+ routeTable.addBlackholeRoute('BlackholeRoute', '172.16.0.0/16');
877
+ ```
878
+
879
+ ### Route Table Associations and Propagations
880
+
881
+ Configure route table associations and enable route propagation:
882
+
883
+ ```ts
884
+ const transitGateway = new TransitGateway(this, 'MyTransitGateway');
885
+ const routeTable = transitGateway.addRouteTable('CustomRouteTable');
886
+ const myVpc = new VpcV2(this, 'Vpc');
887
+ const subnet = new SubnetV2(this, 'Subnet', {
888
+ vpc: myVpc,
889
+ availabilityZone: 'eu-west-2a',
890
+ ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
891
+ subnetType: SubnetType.PUBLIC
892
+ });
893
+ const attachment = transitGateway.attachVpc('VpcAttachment', {
894
+ vpc: myVpc,
895
+ subnets: [subnet]
896
+ });
897
+
898
+ // Associate an attachment with a route table
899
+ routeTable.addAssociation('Association', attachment);
900
+
901
+ // Enable route propagation for an attachment
902
+ routeTable.enablePropagation('Propagation', attachment);
903
+ ```
904
+
905
+ **Associations** — The linking of a Transit Gateway attachment to a specific route table, which determines which routes that attachment will use for routing decisions.
906
+
907
+ **Propagation** — The automatic advertisement of routes from an attachment to a route table, allowing the route table to learn about available network destinations.
package/awslint.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "exclude": [
3
3
  "attribute-tag:@aws-cdk/aws-ec2-alpha.RouteTable.routeTableId",
4
- "from-method:@aws-cdk/aws-ec2-alpha.Route"
4
+ "from-method:@aws-cdk/aws-ec2-alpha.Route",
5
+ "from-method:@aws-cdk/aws-ec2-alpha.TransitGateway",
6
+ "from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayRouteTableAssociation",
7
+ "from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayRouteTablePropagation",
8
+ "from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayVpcAttachment"
5
9
  ]
6
10
  }
package/lib/index.d.ts CHANGED
@@ -3,3 +3,11 @@ export * from './ipam';
3
3
  export * from './vpc-v2-base';
4
4
  export * from './subnet-v2';
5
5
  export * from './route';
6
+ export * from './transit-gateway';
7
+ export * from './transit-gateway-route';
8
+ export * from './transit-gateway-route-table';
9
+ export * from './transit-gateway-attachment';
10
+ export * from './transit-gateway-vpc-attachment';
11
+ export * from './transit-gateway-association';
12
+ export * from './transit-gateway-route-table-association';
13
+ export * from './transit-gateway-route-table-propagation';