-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ec2-alpha): add Transit Gateway L2 (#32956)
### Issue # (if applicable) Closes #17528 ### Description of changes Create new Transit Gateway L2 with the following constructs: * `TransitGateway` * `TransitGatewayRouteTable` * `TransitGatewayRoute` * `TransitGatewayVpcAttachment` * `TransitGatewayRouteTableAssociation` * `TransitGatewayRouteTablePropagation` #### Important Design Decision As described in the README, the CDK disables the creation of the default route table by EC2 and instead the CDK will create a "custom" default route table in its place. This is primarily because there is no way to obtain the route table ID of the EC2 created default route table without a custom resource. The CDK will disable the `defaultRouteTablePropagation` and `defaultRouteTableAssociation` properties on the L1 (when both are disabled, EC2 does not create the default route table), but the properties are still exposed on the CDK TransitGateway interface to allow it to be toggled for the CDK created default route table. The automatic association/propagation is being mimicked by CDK implementation and not relying on the actual EC2 feature. ### Describe any new or updated permissions being added n/a ### Description of how you validated changes Unit + Integration tests to verify that the deployed resources behave as expected. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6b9e47a
commit af44791
Showing
28 changed files
with
3,069 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
"exclude": [ | ||
"attribute-tag:@aws-cdk/aws-ec2-alpha.RouteTable.routeTableId", | ||
"from-method:@aws-cdk/aws-ec2-alpha.Route" | ||
"from-method:@aws-cdk/aws-ec2-alpha.Route", | ||
"from-method:@aws-cdk/aws-ec2-alpha.TransitGateway", | ||
"from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayRouteTableAssociation", | ||
"from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayRouteTablePropagation", | ||
"from-method:@aws-cdk/aws-ec2-alpha.TransitGatewayVpcAttachment" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/aws-ec2-alpha/lib/transit-gateway-association.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IResource, Resource } from 'aws-cdk-lib/core'; | ||
|
||
/** | ||
* Represents a Transit Gateway Route Table Association. | ||
*/ | ||
export interface ITransitGatewayAssociation extends IResource { | ||
/** | ||
* The ID of the transit gateway route table association. | ||
* @attribute | ||
*/ | ||
readonly transitGatewayAssociationId: string; | ||
} | ||
|
||
/** | ||
* A Transit Gateway Association. | ||
* @internal | ||
*/ | ||
export abstract class TransitGatewayAssociationBase extends Resource implements ITransitGatewayAssociation { | ||
public abstract readonly transitGatewayAssociationId: string; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/@aws-cdk/aws-ec2-alpha/lib/transit-gateway-attachment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IResource, Resource } from 'aws-cdk-lib/core'; | ||
/** | ||
* Represents a Transit Gateway Attachment. | ||
*/ | ||
export interface ITransitGatewayAttachment extends IResource { | ||
/** | ||
* The ID of the transit gateway attachment. | ||
* @attribute | ||
*/ | ||
readonly transitGatewayAttachmentId: string; | ||
} | ||
|
||
/** | ||
* A Transit Gateway Attachment. | ||
* @internal | ||
*/ | ||
export abstract class TransitGatewayAttachmentBase extends Resource implements ITransitGatewayAttachment { | ||
public abstract readonly transitGatewayAttachmentId: string; | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/@aws-cdk/aws-ec2-alpha/lib/transit-gateway-route-table-association.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ITransitGatewayAttachment } from './transit-gateway-attachment'; | ||
import { ITransitGatewayRouteTable } from './transit-gateway-route-table'; | ||
import { CfnTransitGatewayRouteTableAssociation } from 'aws-cdk-lib/aws-ec2'; | ||
import { Construct } from 'constructs'; | ||
import { ITransitGatewayAssociation, TransitGatewayAssociationBase } from './transit-gateway-association'; | ||
|
||
/** | ||
* Represents a Transit Gateway Route Table Association. | ||
*/ | ||
export interface ITransitGatewayRouteTableAssociation extends ITransitGatewayAssociation {} | ||
|
||
/** | ||
* Common properties for a Transit Gateway Route Table Association. | ||
*/ | ||
export interface TransitGatewayRouteTableAssociationProps { | ||
/** | ||
* The ID of the transit gateway route table association. | ||
*/ | ||
readonly transitGatewayVpcAttachment: ITransitGatewayAttachment; | ||
|
||
/** | ||
* The ID of the transit gateway route table association. | ||
*/ | ||
readonly transitGatewayRouteTable: ITransitGatewayRouteTable; | ||
|
||
/** | ||
* Physical name of this association. | ||
* | ||
* @default - Assigned by CloudFormation. | ||
*/ | ||
readonly transitGatewayRouteTableAssociationName?: string; | ||
} | ||
|
||
/** | ||
* Create a Transit Gateway Route Table Association. | ||
* | ||
* @resource AWS::EC2::TransitGatewayRouteTableAssociation | ||
*/ | ||
export class TransitGatewayRouteTableAssociation extends TransitGatewayAssociationBase { | ||
/** | ||
* The ID of the transit gateway route table association. | ||
*/ | ||
public readonly transitGatewayAssociationId: string; | ||
|
||
constructor(scope: Construct, id: string, props: TransitGatewayRouteTableAssociationProps) { | ||
super(scope, id); | ||
|
||
const resource = new CfnTransitGatewayRouteTableAssociation(this, id, { | ||
transitGatewayAttachmentId: props.transitGatewayVpcAttachment.transitGatewayAttachmentId, | ||
transitGatewayRouteTableId: props.transitGatewayRouteTable.routeTableId, | ||
}); | ||
this.node.defaultChild = resource; | ||
|
||
this.transitGatewayAssociationId = resource.ref; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/@aws-cdk/aws-ec2-alpha/lib/transit-gateway-route-table-propagation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { IResource, Resource } from 'aws-cdk-lib/core'; | ||
import { CfnTransitGatewayRouteTablePropagation } from 'aws-cdk-lib/aws-ec2'; | ||
import { Construct } from 'constructs'; | ||
import { ITransitGatewayAttachment } from './transit-gateway-attachment'; | ||
import { ITransitGatewayRouteTable } from './transit-gateway-route-table'; | ||
|
||
/** | ||
* Represents a Transit Gateway Route Table Propagation. | ||
*/ | ||
export interface ITransitGatewayRouteTablePropagation extends IResource { | ||
/** | ||
* The ID of the transit gateway route table propagation. | ||
* @attribute | ||
*/ | ||
readonly transitGatewayRouteTablePropagationId: string; | ||
} | ||
|
||
/** | ||
* Common properties for a Transit Gateway Route Table Propagation. | ||
*/ | ||
export interface TransitGatewayRouteTablePropagationProps { | ||
/** | ||
* The ID of the transit gateway route table propagation. | ||
*/ | ||
readonly transitGatewayVpcAttachment: ITransitGatewayAttachment; | ||
|
||
/** | ||
* The ID of the transit gateway route table propagation. | ||
*/ | ||
readonly transitGatewayRouteTable: ITransitGatewayRouteTable; | ||
|
||
/** | ||
* Physical name of this propagation. | ||
* | ||
* @default - Assigned by CloudFormation. | ||
*/ | ||
readonly transitGatewayRouteTablePropagationName?: string; | ||
} | ||
|
||
/** | ||
* Create a Transit Gateway Route Table Propagation. | ||
* | ||
* @resource AWS::EC2::TransitGatewayRouteTablePropagation | ||
*/ | ||
export class TransitGatewayRouteTablePropagation extends Resource implements ITransitGatewayRouteTablePropagation { | ||
/** | ||
* The ID of the transit gateway route table propagation. | ||
*/ | ||
public readonly transitGatewayRouteTablePropagationId: string; | ||
|
||
constructor(scope: Construct, id: string, props: TransitGatewayRouteTablePropagationProps) { | ||
super(scope, id); | ||
|
||
const resource = new CfnTransitGatewayRouteTablePropagation(this, id, { | ||
transitGatewayAttachmentId: props.transitGatewayVpcAttachment.transitGatewayAttachmentId, | ||
transitGatewayRouteTableId: props.transitGatewayRouteTable.routeTableId, | ||
}); | ||
this.node.defaultChild = resource; | ||
|
||
this.transitGatewayRouteTablePropagationId = resource.ref; | ||
} | ||
} |
Oops, something went wrong.