Skip to content

Commit 6c326cb

Browse files
authored
2 parents 5263664 + 4ec69f1 commit 6c326cb

17 files changed

+401
-33
lines changed

CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [1.53.0](https://github.com/aws/aws-cdk/compare/v1.52.0...v1.53.0) (2020-07-20)
6+
7+
8+
### Features
9+
10+
* **ec2:** access a vpc's internet gateway ([#7939](https://github.com/aws/aws-cdk/issues/7939)) ([cb5dad8](https://github.com/aws/aws-cdk/commit/cb5dad8854b59bf89e41348a5e8010ff2e4612f3)), closes [#5327](https://github.com/aws/aws-cdk/issues/5327)
11+
* **lambda-nodejs:** connection reuse with aws-sdk ([#9083](https://github.com/aws/aws-cdk/issues/9083)) ([44c0400](https://github.com/aws/aws-cdk/commit/44c040072362456ebdd15799076a67bbb74e6668))
12+
13+
14+
### Bug Fixes
15+
16+
* **cli:** cli integ tests do not have a unique stack prefix ([#9165](https://github.com/aws/aws-cdk/issues/9165)) ([968c460](https://github.com/aws/aws-cdk/commit/968c460849fdd3bd0ad116ed86de7be55659fbe9))
17+
518
## [1.52.0](https://github.com/aws/aws-cdk/compare/v1.51.0...v1.52.0) (2020-07-18)
619

720

@@ -33,7 +46,6 @@ These can be specifed directly in the OpenAPI spec or via `addMethod()`
3346
* **aws-stepfunctions-tasks:** allow lambda invocations to combine input and function results ([#9022](https://github.com/aws/aws-cdk/issues/9022)) ([846a222](https://github.com/aws/aws-cdk/commit/846a222140984d0aaed948d5bb1f3127a2cc6eb1)), closes [#8943](https://github.com/aws/aws-cdk/issues/8943)
3447
* **certificatemanager:** native CloudFormation DNS validated certificate ([#8552](https://github.com/aws/aws-cdk/issues/8552)) ([337279f](https://github.com/aws/aws-cdk/commit/337279fcce009badc1bb878bdfbcf51ecbef0a38)), closes [#5831](https://github.com/aws/aws-cdk/issues/5831) [#5835](https://github.com/aws/aws-cdk/issues/5835) [#6081](https://github.com/aws/aws-cdk/issues/6081) [#6516](https://github.com/aws/aws-cdk/issues/6516) [#7150](https://github.com/aws/aws-cdk/issues/7150) [#7941](https://github.com/aws/aws-cdk/issues/7941) [#7995](https://github.com/aws/aws-cdk/issues/7995) [#7996](https://github.com/aws/aws-cdk/issues/7996) [#8282](https://github.com/aws/aws-cdk/issues/8282) [#8659](https://github.com/aws/aws-cdk/issues/8659) [#8783](https://github.com/aws/aws-cdk/issues/8783)
3548
* **cfn-include:** add support for nested stacks ([#8980](https://github.com/aws/aws-cdk/issues/8980)) ([bf12456](https://github.com/aws/aws-cdk/commit/bf12456671e171eab16690fc8b54fae6841cf711)), closes [#8978](https://github.com/aws/aws-cdk/issues/8978)
36-
* **cli:** bootstrap stacks are protected from termination by default ([#9002](https://github.com/aws/aws-cdk/issues/9002)) ([0ec7912](https://github.com/aws/aws-cdk/commit/0ec7912a4272ad8729297f775719524a2770083b))
3749
* **cloudfront:** Initial CloudFront redesign ([#8982](https://github.com/aws/aws-cdk/issues/8982)) ([d30fa9d](https://github.com/aws/aws-cdk/commit/d30fa9dda0726230f077c181833fddd40450d6ae))
3850
* **codepipeline:** add support for a StepFunctions invoke action ([#8931](https://github.com/aws/aws-cdk/issues/8931)) ([499776d](https://github.com/aws/aws-cdk/commit/499776de6000b7a18b021b5e17d22078e55f66d9))
3951
* **core:** cloudformation resource metadata ([#9063](https://github.com/aws/aws-cdk/issues/9063)) ([b0f8729](https://github.com/aws/aws-cdk/commit/b0f8729002b90c1c90ca46a4db9e297a69fef174)), closes [#8788](https://github.com/aws/aws-cdk/issues/8788)

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,14 @@ $ lr pkglint
361361

362362
**awslint** is a linter for the AWS Construct Library APIs. It is executed as a
363363
part of the build of all AWS modules in the project and enforces the [AWS
364-
Construct Library Design Guidelines](./design/aws-guidelines.md).
364+
Construct Library Design Guidelines](./DESIGN_GUIDELINES.md).
365365

366366
For more information about this tool, see the [awslint
367367
README](./tools/awslint/README.md).
368368

369369
Generally speaking, if you make any changes which violate an awslint rule, build
370370
will fail with appropriate messages. All rules are documented and explained in
371-
the [guidelines](./design/aws-guidelines.md).
371+
the [guidelines](./DESIGN_GUIDELINES.md).
372372

373373
Here are a few useful commands:
374374

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"tools/*"
1111
],
1212
"rejectCycles": "true",
13-
"version": "1.52.0"
13+
"version": "1.53.0"
1414
}

packages/@aws-cdk/aws-ec2/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,51 @@ DatabaseSubnet1 |`ISOLATED`|`10.0.6.0/28` |#1|Only routes within the VPC
252252
DatabaseSubnet2 |`ISOLATED`|`10.0.6.16/28`|#2|Only routes within the VPC
253253
DatabaseSubnet3 |`ISOLATED`|`10.0.6.32/28`|#3|Only routes within the VPC
254254

255+
### Accessing the Internet Gateway
256+
257+
If you need access to the internet gateway, you can get it's ID like so:
258+
259+
```ts
260+
const igwId = vpc.internetGatewayId;
261+
```
262+
263+
For a VPC with only `ISOLATED` subnets, this value will be undefined.
264+
265+
This is only supported for VPC's created in the stack - currently you're
266+
unable to get the ID for imported VPC's. To do that you'd have to specifically
267+
look up the Internet Gateway by name, which would require knowing the name
268+
beforehand.
269+
270+
This can be useful for configuring routing using a combination of gateways:
271+
for more information see [Routing](#routing) below.
272+
273+
#### Routing
274+
275+
It's possible to add routes to any subnets using the `addRoute()` method. If for
276+
example you want an isolated subnet to have a static route via the default
277+
Internet Gateway created for the public subnet - perhaps for routing a VPN
278+
connection - you can do so like this:
279+
280+
```ts
281+
const vpc = ec2.Vpc(this, "VPC", {
282+
subnetConfiguration: [{
283+
subnetType: SubnetType.PUBLIC,
284+
name: 'Public',
285+
},{
286+
subnetType: SubnetType.ISOLATED,
287+
name: 'Isolated',
288+
}]
289+
})
290+
(vpc.isolatedSubnets[0] as Subnet).addRoute("StaticRoute", {
291+
routerId: vpc.internetGatewayId,
292+
routerType: RouterType.GATEWAY,
293+
destinationCidrBlock: "8.8.8.8/32",
294+
})
295+
```
296+
297+
*Note that we cast to `Subnet` here because the list of subnets only returns an
298+
`ISubnet`.*
299+
255300
### Reserving subnet IP space
256301

257302
There are situations where the IP space for a subnet or number of subnets

packages/@aws-cdk/aws-ec2/lib/vpc.ts

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export interface IVpc extends IResource {
9494
* Identifier for the VPN gateway
9595
*/
9696
readonly vpnGatewayId?: string;
97+
9798
/**
9899
* Dependable that can be depended upon to force internet connectivity established on the VPC
99100
*/
@@ -1098,6 +1099,12 @@ export class Vpc extends VpcBase {
10981099
*/
10991100
public readonly availabilityZones: string[];
11001101

1102+
/**
1103+
* Internet Gateway for the VPC. Note that in case the VPC is configured only
1104+
* with ISOLATED subnets, this attribute will be `undefined`.
1105+
*/
1106+
public readonly internetGatewayId?: string;
1107+
11011108
public readonly internetConnectivityEstablished: IDependable;
11021109

11031110
/**
@@ -1184,6 +1191,9 @@ export class Vpc extends VpcBase {
11841191
if (allowOutbound) {
11851192
const igw = new CfnInternetGateway(this, 'IGW', {
11861193
});
1194+
1195+
this.internetGatewayId = igw.ref;
1196+
11871197
this._internetConnectivityEstablished.add(igw);
11881198
const att = new CfnVPCGatewayAttachment(this, 'VPCGW', {
11891199
internetGatewayId: igw.ref,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"Resources": {
3+
"MyVpcF9F0CA6F": {
4+
"Type": "AWS::EC2::VPC",
5+
"Properties": {
6+
"CidrBlock": "10.0.0.0/16",
7+
"EnableDnsHostnames": true,
8+
"EnableDnsSupport": true,
9+
"InstanceTenancy": "default",
10+
"Tags": [
11+
{
12+
"Key": "Name",
13+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc"
14+
}
15+
]
16+
}
17+
},
18+
"MyVpcPublicSubnet1SubnetF6608456": {
19+
"Type": "AWS::EC2::Subnet",
20+
"Properties": {
21+
"CidrBlock": "10.0.0.0/17",
22+
"VpcId": {
23+
"Ref": "MyVpcF9F0CA6F"
24+
},
25+
"AvailabilityZone": "test-region-1a",
26+
"MapPublicIpOnLaunch": true,
27+
"Tags": [
28+
{
29+
"Key": "aws-cdk:subnet-name",
30+
"Value": "Public"
31+
},
32+
{
33+
"Key": "aws-cdk:subnet-type",
34+
"Value": "Public"
35+
},
36+
{
37+
"Key": "Name",
38+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc/PublicSubnet1"
39+
}
40+
]
41+
}
42+
},
43+
"MyVpcPublicSubnet1RouteTableC46AB2F4": {
44+
"Type": "AWS::EC2::RouteTable",
45+
"Properties": {
46+
"VpcId": {
47+
"Ref": "MyVpcF9F0CA6F"
48+
},
49+
"Tags": [
50+
{
51+
"Key": "Name",
52+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc/PublicSubnet1"
53+
}
54+
]
55+
}
56+
},
57+
"MyVpcPublicSubnet1RouteTableAssociation2ECEE1CB": {
58+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
59+
"Properties": {
60+
"RouteTableId": {
61+
"Ref": "MyVpcPublicSubnet1RouteTableC46AB2F4"
62+
},
63+
"SubnetId": {
64+
"Ref": "MyVpcPublicSubnet1SubnetF6608456"
65+
}
66+
}
67+
},
68+
"MyVpcPublicSubnet1DefaultRoute95FDF9EB": {
69+
"Type": "AWS::EC2::Route",
70+
"Properties": {
71+
"RouteTableId": {
72+
"Ref": "MyVpcPublicSubnet1RouteTableC46AB2F4"
73+
},
74+
"DestinationCidrBlock": "0.0.0.0/0",
75+
"GatewayId": {
76+
"Ref": "MyVpcIGW5C4A4F63"
77+
}
78+
},
79+
"DependsOn": [
80+
"MyVpcVPCGW488ACE0D"
81+
]
82+
},
83+
"MyVpcIsolatedSubnet1Subnet2259FE9F": {
84+
"Type": "AWS::EC2::Subnet",
85+
"Properties": {
86+
"CidrBlock": "10.0.128.0/17",
87+
"VpcId": {
88+
"Ref": "MyVpcF9F0CA6F"
89+
},
90+
"AvailabilityZone": "test-region-1a",
91+
"MapPublicIpOnLaunch": false,
92+
"Tags": [
93+
{
94+
"Key": "aws-cdk:subnet-name",
95+
"Value": "Isolated"
96+
},
97+
{
98+
"Key": "aws-cdk:subnet-type",
99+
"Value": "Isolated"
100+
},
101+
{
102+
"Key": "Name",
103+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc/IsolatedSubnet1"
104+
}
105+
]
106+
}
107+
},
108+
"MyVpcIsolatedSubnet1RouteTable67AEA7B8": {
109+
"Type": "AWS::EC2::RouteTable",
110+
"Properties": {
111+
"VpcId": {
112+
"Ref": "MyVpcF9F0CA6F"
113+
},
114+
"Tags": [
115+
{
116+
"Key": "Name",
117+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc/IsolatedSubnet1"
118+
}
119+
]
120+
}
121+
},
122+
"MyVpcIsolatedSubnet1RouteTableAssociationCDAE5449": {
123+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
124+
"Properties": {
125+
"RouteTableId": {
126+
"Ref": "MyVpcIsolatedSubnet1RouteTable67AEA7B8"
127+
},
128+
"SubnetId": {
129+
"Ref": "MyVpcIsolatedSubnet1Subnet2259FE9F"
130+
}
131+
}
132+
},
133+
"MyVpcIsolatedSubnet1MyRouteCDD7D172": {
134+
"Type": "AWS::EC2::Route",
135+
"Properties": {
136+
"RouteTableId": {
137+
"Ref": "MyVpcIsolatedSubnet1RouteTable67AEA7B8"
138+
},
139+
"DestinationCidrBlock": "8.8.8.8/32",
140+
"GatewayId": {
141+
"Ref": "MyVpcIGW5C4A4F63"
142+
}
143+
}
144+
},
145+
"MyVpcIGW5C4A4F63": {
146+
"Type": "AWS::EC2::InternetGateway",
147+
"Properties": {
148+
"Tags": [
149+
{
150+
"Key": "Name",
151+
"Value": "aws-cdk-ec2-vpc-gateway/MyVpc"
152+
}
153+
]
154+
}
155+
},
156+
"MyVpcVPCGW488ACE0D": {
157+
"Type": "AWS::EC2::VPCGatewayAttachment",
158+
"Properties": {
159+
"VpcId": {
160+
"Ref": "MyVpcF9F0CA6F"
161+
},
162+
"InternetGatewayId": {
163+
"Ref": "MyVpcIGW5C4A4F63"
164+
}
165+
}
166+
}
167+
}
168+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as cdk from '@aws-cdk/core';
2+
import * as ec2 from '../lib';
3+
4+
const app = new cdk.App();
5+
const stack = new cdk.Stack(app, 'aws-cdk-ec2-vpc-gateway');
6+
7+
const vpc = new ec2.Vpc(stack, 'MyVpc', {
8+
maxAzs: 1,
9+
subnetConfiguration: [
10+
{
11+
subnetType: ec2.SubnetType.PUBLIC,
12+
name: 'Public',
13+
},
14+
{
15+
subnetType: ec2.SubnetType.ISOLATED,
16+
name: 'Isolated',
17+
},
18+
],
19+
});
20+
21+
(vpc.isolatedSubnets[0] as ec2.Subnet).addRoute('MyRoute', {
22+
routerId: vpc.internetGatewayId!,
23+
routerType: ec2.RouterType.GATEWAY,
24+
destinationCidrBlock: '8.8.8.8/32',
25+
});
26+
27+
app.synth();

0 commit comments

Comments
 (0)