Skip to content

Commit 1529743

Browse files
authored
2 parents c42e961 + 41c9348 commit 1529743

File tree

77 files changed

+3012
-2149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3012
-2149
lines changed

CHANGELOG.v2.alpha.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
## [2.30.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.29.1-alpha.0...v2.30.0-alpha.0) (2022-07-01)
6+
57
## [2.29.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.29.0-alpha.0...v2.29.1-alpha.0) (2022-06-24)
68

79
## [2.29.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.28.1-alpha.0...v2.29.0-alpha.0) (2022-06-22)

CHANGELOG.v2.md

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
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+
## [2.30.0](https://github.com/aws/aws-cdk/compare/v2.29.1...v2.30.0) (2022-07-01)
6+
7+
### Features
8+
9+
* **appmesh:** ipv6 support for app mesh ([#20766](https://github.com/aws/aws-cdk/issues/20766)) ([b1e6d62](https://github.com/aws/aws-cdk/commit/b1e6d62ed6b6ede0362d0a68d804660e84efe5cb)), closes [#20737](https://github.com/aws/aws-cdk/issues/20737)
10+
* **cognito:** make `grant()` available on `IUserPool` ([#20799](https://github.com/aws/aws-cdk/issues/20799)) ([a1df570](https://github.com/aws/aws-cdk/commit/a1df570b89c6d456077bb934e0bf08217677ef1f)), closes [#20285](https://github.com/aws/aws-cdk/issues/20285)
11+
* **iam:** PolicyStatements can be frozen ([#20911](https://github.com/aws/aws-cdk/issues/20911)) ([3bf737b](https://github.com/aws/aws-cdk/commit/3bf737bd172eda016d2e9bb7c5f40c001399fd23))
12+
* **lambda:** grant function permissions to an AWS organization ([#19975](https://github.com/aws/aws-cdk/issues/19975)) ([2566017](https://github.com/aws/aws-cdk/commit/2566017a83ec4f9c2c5cefda4585a3f71e3516e7)), closes [#19538](https://github.com/aws/aws-cdk/issues/19538) [#20146](https://github.com/aws/aws-cdk/issues/20146)
13+
* **rds:** add missing aurora postgres versions ([#20830](https://github.com/aws/aws-cdk/issues/20830)) ([2151a0e](https://github.com/aws/aws-cdk/commit/2151a0e9b988723e050e6f37ed1780cced16c519))
14+
15+
16+
### Bug Fixes
17+
18+
* **apigateway:** Explicitly test for undefined instead of falsey for stage default options ([#20868](https://github.com/aws/aws-cdk/issues/20868)) ([b368a31](https://github.com/aws/aws-cdk/commit/b368a315cab0cedf03298083f5f1fb809bd1d1f2))
19+
* **eks:** revert shell=True and allow public ecr to work ([#20724](https://github.com/aws/aws-cdk/issues/20724)) ([de153fc](https://github.com/aws/aws-cdk/commit/de153fcdd47a4cdcd1d156d5e19684969d990c8e))
20+
* **pipelines:** 'ConfirmPermissionsBroadening' uses wrong node version ([#20861](https://github.com/aws/aws-cdk/issues/20861)) ([bac965e](https://github.com/aws/aws-cdk/commit/bac965e9c4d435ae45d5cf16aa809f33bbb05a0f))
21+
* **secretsmanager:** SecretRotation app does not set DeletionPolicy ([#20901](https://github.com/aws/aws-cdk/issues/20901)) ([f2b4eff](https://github.com/aws/aws-cdk/commit/f2b4effc903ab3a36dc925516f3329f236d03a70))
22+
523
## [2.29.1](https://github.com/aws/aws-cdk/compare/v2.29.0...v2.29.1) (2022-06-24)
624

725

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
[![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-cdk-go/awscdk.svg)](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk)
1010
[![Mergify](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/aws/aws-cdk&style=flat)](https://mergify.io)
1111

12+
[![View on Construct Hub](https://constructs.dev/badge?package=aws-cdk-lib)](https://constructs.dev/packages/aws-cdk-lib)
13+
1214
The **AWS Cloud Development Kit (AWS CDK)** is an open-source software development
1315
framework to define cloud infrastructure in code and provision it through AWS CloudFormation.
1416

packages/@aws-cdk/aws-apigateway/lib/stage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export class Stage extends Resource implements IStage {
310310
};
311311

312312
// if any of them are defined, add an entry for '/*/*'.
313-
const hasCommonOptions = Object.keys(commonMethodOptions).map(v => (commonMethodOptions as any)[v]).filter(x => x).length > 0;
313+
const hasCommonOptions = Object.keys(commonMethodOptions).map(v => (commonMethodOptions as any)[v]).filter(x => x !== undefined).length > 0;
314314
if (hasCommonOptions) {
315315
settings.push(renderEntry('/*/*', commonMethodOptions));
316316
}

packages/@aws-cdk/aws-apigateway/test/stage.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Template } from '@aws-cdk/assertions';
22
import * as logs from '@aws-cdk/aws-logs';
33
import * as cdk from '@aws-cdk/core';
44
import * as apigateway from '../lib';
5+
import { ApiDefinition } from '../lib';
56

67
describe('stage', () => {
78
test('minimal setup', () => {
@@ -396,4 +397,30 @@ describe('stage', () => {
396397
accessLogFormat: testFormat,
397398
})).toThrow(/Access log format is specified without a destination/);
398399
});
400+
401+
test('default throttling settings', () => {
402+
// GIVEN
403+
const stack = new cdk.Stack();
404+
new apigateway.SpecRestApi(stack, 'testapi', {
405+
apiDefinition: ApiDefinition.fromInline({
406+
openapi: '3.0.2',
407+
}),
408+
deployOptions: {
409+
throttlingBurstLimit: 0,
410+
throttlingRateLimit: 0,
411+
metricsEnabled: false,
412+
},
413+
});
414+
415+
// THEN
416+
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Stage', {
417+
MethodSettings: [{
418+
DataTraceEnabled: false,
419+
HttpMethod: '*',
420+
ResourcePath: '/*',
421+
ThrottlingBurstLimit: 0,
422+
ThrottlingRateLimit: 0,
423+
}],
424+
});
425+
});
399426
});

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

+53
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ const mesh = new appmesh.Mesh(this, 'AppMesh', {
4949
});
5050
```
5151

52+
A mesh with an IP preference can be created by providing the property `serviceDiscovery` that specifes an `ipPreference`.
53+
54+
```ts
55+
const mesh = new appmesh.Mesh(this, 'AppMesh', {
56+
meshName: 'myAwsMesh',
57+
serviceDiscovery: {
58+
ipPreference: appmesh.IpPreference.IPV4_ONLY,
59+
},
60+
});
61+
```
62+
5263
## Adding VirtualRouters
5364

5465
A _mesh_ uses _virtual routers_ as logical units to route requests to _virtual nodes_.
@@ -425,6 +436,48 @@ const gateway = new appmesh.VirtualGateway(this, 'gateway', {
425436
});
426437
```
427438

439+
### Adding an IP Preference to a Virtual Node
440+
441+
An `ipPreference` can be specified as part of a Virtual Node's service discovery. An IP preference defines how clients for this Virtual Node will interact with it.
442+
443+
There a four different IP preferences available to use which each specify what IP versions this Virtual Node will use and prefer.
444+
445+
- `IPv4_ONLY` - Only use IPv4. For CloudMap service discovery, only IPv4 addresses returned from CloudMap will be used. For DNS service discovery, Envoy's DNS resolver will only resolve DNS queries for IPv4.
446+
447+
- `IPv4_PREFERRED` - Prefer IPv4 and fall back to IPv6. For CloudMap service discovery, an IPv4 address will be used if returned from CloudMap. Otherwise, an IPv6 address will be used if available. For DNS service discovery, Envoy's DNS resolver will first attempt to resolve DNS queries using IPv4 and fall back to IPv6.
448+
449+
- `IPv6_ONLY` - Only use IPv6. For CloudMap service discovery, only IPv6 addresses returned from CloudMap will be used. For DNS service discovery, Envoy's DNS resolver will only resolve DNS queries for IPv6.
450+
451+
- `IPv6_PREFERRED` - Prefer IPv6 and fall back to IPv4. For CloudMap service discovery, an IPv6 address will be used if returned from CloudMap. Otherwise, an IPv4 address will be used if available. For DNS service discovery, Envoy's DNS resolver will first attempt to resolve DNS queries using IPv6 and fall back to IPv4.
452+
453+
```ts
454+
const mesh = new appmesh.Mesh(stack, 'mesh', {
455+
meshName: 'mesh-with-preference',
456+
});
457+
458+
// Virtual Node with DNS service discovery and an IP preference
459+
const dnsNode = new appmesh.VirtualNode(stack, 'dns-node', {
460+
mesh,
461+
serviceDiscovery: appmesh.ServiceDiscovery.dns('test', appmesh.DnsResponseType.LOAD_BALANCER, appmesh.IpPreference.IPV4_ONLY),
462+
});
463+
464+
// Virtual Node with CloudMap service discovery and an IP preference
465+
const vpc = new ec2.Vpc(stack, 'vpc');
466+
const namespace = new cloudmap.PrivateDnsNamespace(stack, 'test-namespace', {
467+
vpc,
468+
name: 'domain.local',
469+
});
470+
const service = namespace.createService('Svc');
471+
472+
const instanceAttribute : { [key: string]: string} = {};
473+
instanceAttribute.testKey = 'testValue';
474+
475+
const cloudmapNode = new appmesh.VirtualNode(stack, 'cloudmap-node', {
476+
mesh,
477+
serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service, instanceAttribute, appmesh.IpPreference.IPV4_ONLY),
478+
});
479+
```
480+
428481
## Adding a Route
429482

430483
A _route_ matches requests with an associated virtual router and distributes traffic to its associated virtual nodes.

packages/@aws-cdk/aws-appmesh/lib/mesh.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as cdk from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { CfnMesh } from './appmesh.generated';
4+
import { MeshServiceDiscovery } from './service-discovery';
45
import { VirtualGateway, VirtualGatewayBaseProps } from './virtual-gateway';
56
import { VirtualNode, VirtualNodeBaseProps } from './virtual-node';
67
import { VirtualRouter, VirtualRouterBaseProps } from './virtual-router';
@@ -124,6 +125,13 @@ export interface MeshProps {
124125
* @default DROP_ALL
125126
*/
126127
readonly egressFilter?: MeshFilterType;
128+
129+
/**
130+
* Defines how upstream clients will discover VirtualNodes in the Mesh
131+
*
132+
* @default - No Service Discovery
133+
*/
134+
readonly serviceDiscovery?: MeshServiceDiscovery;
127135
}
128136

129137
/**
@@ -187,6 +195,7 @@ export class Mesh extends MeshBase {
187195
egressFilter: props.egressFilter ? {
188196
type: props.egressFilter,
189197
} : undefined,
198+
serviceDiscovery: props.serviceDiscovery,
190199
},
191200
});
192201

packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts

+60-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,52 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery';
22
import { Construct } from 'constructs';
33
import { CfnVirtualNode } from './appmesh.generated';
44

5+
/**
6+
* Enum of supported IP preferences.
7+
* Used to dictate the IP version for mesh wide and virtual node service discovery.
8+
* Also used to specify the IP version that a sidecar Envoy uses when sending traffic to a local application.
9+
*/
10+
11+
export enum IpPreference {
12+
/**
13+
* Use IPv4 when sending traffic to a local application.
14+
* Only use IPv4 for service discovery.
15+
*/
16+
IPV4_ONLY = 'IPv4_ONLY',
17+
/**
18+
* Use IPv4 when sending traffic to a local application.
19+
* First attempt to use IPv4 and fall back to IPv6 for service discovery.
20+
*/
21+
IPV4_PREFERRED = 'IPv4_PREFERRED',
22+
/**
23+
* Use IPv6 when sending traffic to a local application.
24+
* Only use IPv6 for service discovery.
25+
*/
26+
IPV6_ONLY = 'IPv6_ONLY',
27+
/**
28+
* Use IPv6 when sending traffic to a local application.
29+
* First attempt to use IPv6 and fall back to IPv4 for service discovery.
30+
*/
31+
IPV6_PREFERRED = 'IPv6_PREFERRED'
32+
}
33+
34+
/**
35+
* Properties for Mesh Service Discovery
36+
*/
37+
export interface MeshServiceDiscovery {
38+
/**
39+
* IP preference applied to all Virtual Nodes in the Mesh
40+
*
41+
* @default - No IP preference is applied to any of the Virtual Nodes in the Mesh.
42+
* Virtual Nodes without an IP preference will have the following configured.
43+
* Envoy listeners are configured to bind only to IPv4.
44+
* Envoy will use IPv4 when sending traffic to a local application.
45+
* For DNS service discovery, the Envoy DNS resolver to prefer using IPv6 and fall back to IPv4.
46+
* For CloudMap service discovery, App Mesh will prefer using IPv4 and fall back to IPv6 for IPs returned by CloudMap.
47+
*/
48+
readonly ipPreference?: IpPreference;
49+
}
50+
551
/**
652
* Properties for VirtualNode Service Discovery
753
*/
@@ -48,9 +94,10 @@ export abstract class ServiceDiscovery {
4894
* @param hostname
4995
* @param responseType Specifies the DNS response type for the virtual node.
5096
* The default is `DnsResponseType.LOAD_BALANCER`.
97+
* @param ipPreference No IP preference is applied to the Virtual Node.
5198
*/
52-
public static dns(hostname: string, responseType?: DnsResponseType): ServiceDiscovery {
53-
return new DnsServiceDiscovery(hostname, responseType);
99+
public static dns(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference): ServiceDiscovery {
100+
return new DnsServiceDiscovery(hostname, responseType, ipPreference);
54101
}
55102

56103
/**
@@ -61,9 +108,10 @@ export abstract class ServiceDiscovery {
61108
* filter instances by any custom attribute that you specified when you
62109
* registered the instance. Only instances that match all of the specified
63110
* key/value pairs will be returned.
111+
* @param ipPreference No IP preference is applied to the Virtual Node.
64112
*/
65-
public static cloudMap(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}): ServiceDiscovery {
66-
return new CloudMapServiceDiscovery(service, instanceAttributes);
113+
public static cloudMap(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}, ipPreference?: IpPreference): ServiceDiscovery {
114+
return new CloudMapServiceDiscovery(service, instanceAttributes, ipPreference);
67115
}
68116

69117
/**
@@ -75,18 +123,21 @@ export abstract class ServiceDiscovery {
75123
class DnsServiceDiscovery extends ServiceDiscovery {
76124
private readonly hostname: string;
77125
private readonly responseType?: DnsResponseType;
126+
private readonly ipPreference?: IpPreference;
78127

79-
constructor(hostname: string, responseType?: DnsResponseType) {
128+
constructor(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference) {
80129
super();
81130
this.hostname = hostname;
82131
this.responseType = responseType;
132+
this.ipPreference = ipPreference;
83133
}
84134

85135
public bind(_scope: Construct): ServiceDiscoveryConfig {
86136
return {
87137
dns: {
88138
hostname: this.hostname,
89139
responseType: this.responseType,
140+
ipPreference: this.ipPreference,
90141
},
91142
};
92143
}
@@ -95,11 +146,13 @@ class DnsServiceDiscovery extends ServiceDiscovery {
95146
class CloudMapServiceDiscovery extends ServiceDiscovery {
96147
private readonly service: cloudmap.IService;
97148
private readonly instanceAttributes?: {[key: string]: string};
149+
private readonly ipPreference?: IpPreference;
98150

99-
constructor(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}) {
151+
constructor(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}, ipPreference?: IpPreference) {
100152
super();
101153
this.service = service;
102154
this.instanceAttributes = instanceAttributes;
155+
this.ipPreference = ipPreference;
103156
}
104157

105158
public bind(_scope: Construct): ServiceDiscoveryConfig {
@@ -108,6 +161,7 @@ class CloudMapServiceDiscovery extends ServiceDiscovery {
108161
namespaceName: this.service.namespace.namespaceName,
109162
serviceName: this.service.serviceName,
110163
attributes: renderAttributes(this.instanceAttributes),
164+
ipPreference: this.ipPreference,
111165
},
112166
};
113167
}

packages/@aws-cdk/aws-appmesh/test/integ.mesh.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const namespace = new cloudmap.PrivateDnsNamespace(stack, 'test-namespace', {
1717
});
1818

1919
const mesh = new appmesh.Mesh(stack, 'mesh');
20+
new appmesh.Mesh(stack, 'mesh-with-preference', {
21+
serviceDiscovery: {
22+
ipPreference: appmesh.IpPreference.IPV4_ONLY,
23+
},
24+
});
2025
const router = mesh.addVirtualRouter('router', {
2126
listeners: [
2227
appmesh.VirtualRouterListener.http(),
@@ -29,7 +34,7 @@ const virtualService = new appmesh.VirtualService(stack, 'service', {
2934
});
3035

3136
const node = mesh.addVirtualNode('node', {
32-
serviceDiscovery: appmesh.ServiceDiscovery.dns(`node1.${namespace.namespaceName}`),
37+
serviceDiscovery: appmesh.ServiceDiscovery.dns(`node1.${namespace.namespaceName}`, undefined, appmesh.IpPreference.IPV4_ONLY),
3338
listeners: [appmesh.VirtualNodeListener.http({
3439
healthCheck: appmesh.HealthCheck.http({
3540
healthyThreshold: 3,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"17.0.0"}
1+
{"version":"20.0.0"}

packages/@aws-cdk/aws-appmesh/test/mesh.integ.snapshot/integ.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"version": "18.0.0",
2+
"version": "20.0.0",
33
"testCases": {
4-
"aws-appmesh/test/integ.mesh": {
4+
"integ.mesh": {
55
"stacks": [
66
"mesh-stack"
77
],

packages/@aws-cdk/aws-appmesh/test/mesh.integ.snapshot/manifest.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "17.0.0",
2+
"version": "20.0.0",
33
"artifacts": {
44
"Tree": {
55
"type": "cdk:tree",
@@ -291,6 +291,12 @@
291291
"data": "meshgateway1gateway1routegrpc2FAC1FF36"
292292
}
293293
],
294+
"/mesh-stack/mesh-with-preference/Resource": [
295+
{
296+
"type": "aws:cdk:logicalId",
297+
"data": "meshwithpreferenceCC9682C9"
298+
}
299+
],
294300
"/mesh-stack/service/Resource": [
295301
{
296302
"type": "aws:cdk:logicalId",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "20.0.0",
3+
"files": {
4+
"be244c434fce5ce2d030a96121c147910d423314d1807320ddf66a562a53550d": {
5+
"source": {
6+
"path": "mesh-stack.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "be244c434fce5ce2d030a96121c147910d423314d1807320ddf66a562a53550d.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)