-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
integ.reserved-private-subnet.ts
40 lines (36 loc) · 1.08 KB
/
integ.reserved-private-subnet.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/core';
import * as ec2 from '../lib';
/*
* Creates a simple vpc with a public subnet and a private reserved subnet.
* Public subnet should be visible but a private reserved subnet only has IP space reserved.
* No resources are provisioned in a reserved subnet.
*
* Stack verification steps:
* -- aws ec2 describe-nat-gateways returns { "natGateways": []}
*/
const app = new cdk.App();
class VpcReservedPrivateSubnetStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
/// !show
// Specify no NAT gateways with a reserved private subnet
new ec2.Vpc(this, 'VPC', {
cidr: '10.0.0.0/16',
subnetConfiguration: [
{
name: 'ingress',
subnetType: ec2.SubnetType.PUBLIC,
},
{
name: 'private',
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
reserved: true,
},
],
natGateways: 0,
});
/// !hide
}
}
new VpcReservedPrivateSubnetStack(app, 'aws-cdk-ec2-vpc-endpoint');
app.synth();