-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
integ.nat-instances.lit.ts
40 lines (33 loc) · 1.21 KB
/
integ.nat-instances.lit.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
import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
class NatInstanceStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
/// !show
// Configure the `natGatewayProvider` when defining a Vpc
const natGatewayProvider = ec2.NatProvider.instance({
instanceType: new ec2.InstanceType('t3.small'),
});
const vpc = new ec2.Vpc(this, 'MyVpc', {
natGatewayProvider,
// The 'natGateways' parameter now controls the number of NAT instances
natGateways: 2,
});
/// !hide
Array.isArray(vpc);
Array.isArray(natGatewayProvider.configuredGateways);
}
}
const app = new cdk.App();
const testCase = new NatInstanceStack(app, 'aws-cdk-vpc-nat-instances', {
env: {
account: process.env.CDK_INTEG_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_INTEG_REGION || process.env.CDK_DEFAULT_REGION,
},
});
new IntegTest(app, 'integ-test', {
testCases: [testCase],
});