-
Notifications
You must be signed in to change notification settings - Fork 0
/
integ.transitGateway.ts
41 lines (33 loc) · 1.34 KB
/
integ.transitGateway.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import cdk = require("aws-cdk-lib");
import { Construct } from 'constructs';
import ec2 = require('aws-cdk-lib/aws-ec2');
import { VpcProvider } from '../vpc';
//
export interface TransitGatewayStackProps extends cdk.StackProps {
// readonly cidr?: string;
}
export class TransitGatewayStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: TransitGatewayStackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'ExistingVPC', { vpcName: 'vpcSample/Vpc' }) || VpcProvider.createSimple(this);
const tgw = new ec2.CfnTransitGateway(this,"TransitGateway", {
amazonSideAsn: 65432,
autoAcceptSharedAttachments: "enable",
dnsSupport: "enable",
vpnEcmpSupport: "enable",
});
var tgwAttachment = new ec2.CfnTransitGatewayAttachment(this, "TransitGatewayAttachment", {
subnetIds: vpc.selectSubnets().subnetIds,
transitGatewayId: tgw.ref,
vpcId: vpc.vpcId
});
new cdk.CfnOutput(this, 'transitGatewayId', { value: tgw.ref })
new cdk.CfnOutput(this, 'transitGatewayArn', {
value: cdk.Stack.of(this).formatArn({
service: 'ec2',
resource: 'transit-gateway',
resourceName: tgw.ref
})
})
}
}