Skip to content

Commit dd5e12d

Browse files
authored
2 parents 2dea31a + ce6137f commit dd5e12d

File tree

90 files changed

+8831
-1409
lines changed

Some content is hidden

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

90 files changed

+8831
-1409
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
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+
## [1.134.0](https://github.com/aws/aws-cdk/compare/v1.133.0...v1.134.0) (2021-11-23)
6+
7+
8+
### Features
9+
10+
* **apigatewayv2:** domain endpoint type, security policy and endpoint migration ([#17518](https://github.com/aws/aws-cdk/issues/17518)) ([261b331](https://github.com/aws/aws-cdk/commit/261b331e89be01dc996d153c91b4018e7ddfda29))
11+
* **cfnspec:** cloudformation spec v49.0.0 ([#17621](https://github.com/aws/aws-cdk/issues/17621)) ([ce638b4](https://github.com/aws/aws-cdk/commit/ce638b407ac9efc6a3ee4d5ecd22c68ab68b8e58))
12+
* **docdb:** add option to set the name of the generated Secret ([#17574](https://github.com/aws/aws-cdk/issues/17574)) ([18c9ef7](https://github.com/aws/aws-cdk/commit/18c9ef713717fcb2f84e687c1e34c887a50264bd)), closes [#17572](https://github.com/aws/aws-cdk/issues/17572)
13+
* **eks:** ALB Controller ([#17618](https://github.com/aws/aws-cdk/issues/17618)) ([1faf31d](https://github.com/aws/aws-cdk/commit/1faf31d1ec7ffec4c6323a050126b0b054094c63))
14+
* **msk:** add Kafka version 2.6.2 ([#17497](https://github.com/aws/aws-cdk/issues/17497)) ([5f1f476](https://github.com/aws/aws-cdk/commit/5f1f4762e964345741426fa1242320a5fc117338))
15+
16+
17+
### Bug Fixes
18+
19+
* **assets:** add missing SAM asset metadata information ([#17591](https://github.com/aws/aws-cdk/issues/17591)) ([55df760](https://github.com/aws/aws-cdk/commit/55df760fdd9514384de019e5ce338d5250c7df97)), closes [#14593](https://github.com/aws/aws-cdk/issues/14593)
20+
* **aws-ecs:** check for invalid capacityProviderName ([#17291](https://github.com/aws/aws-cdk/issues/17291)) ([6e2fde4](https://github.com/aws/aws-cdk/commit/6e2fde452de73c51011ddb14ede40ca0471d3663)), closes [#17321](https://github.com/aws/aws-cdk/issues/17321)
21+
* **opensearch:** correctly validate ebs configuration against instance types ([#16911](https://github.com/aws/aws-cdk/issues/16911)) ([34af598](https://github.com/aws/aws-cdk/commit/34af5988b7c1ff003d10612150191803f762a79f)), closes [#11898](https://github.com/aws/aws-cdk/issues/11898)
22+
523
## [1.133.0](https://github.com/aws/aws-cdk/compare/v1.132.0...v1.133.0) (2021-11-19)
624

725

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"fs-extra": "^9.1.0",
2121
"graceful-fs": "^4.2.8",
2222
"jest-junit": "^13.0.0",
23-
"jsii-diff": "^1.45.0",
24-
"jsii-pacmak": "^1.45.0",
25-
"jsii-reflect": "^1.45.0",
26-
"jsii-rosetta": "^1.45.0",
23+
"jsii-diff": "^1.46.0",
24+
"jsii-pacmak": "^1.46.0",
25+
"jsii-reflect": "^1.46.0",
26+
"jsii-rosetta": "^1.46.0",
2727
"lerna": "^4.0.0",
2828
"patch-package": "^6.4.7",
2929
"standard-version": "^9.3.2",

packages/@aws-cdk/assertions/rosetta/default.ts-fixture

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Construct, Stack } from '@aws-cdk/core';
1+
// Fixture with packages imported, but nothing else
2+
import { Construct } from 'constructs';
3+
import { Stack } from '@aws-cdk/core';
24
import { Capture, Match, Template } from '@aws-cdk/assertions';
35

46
class Fixture extends Stack {

packages/@aws-cdk/aws-apigateway/rosetta/default.ts-fixture

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Fixture with packages imported, but nothing else
2-
import { Construct, Stack } from '@aws-cdk/core';
2+
import { Construct } from 'constructs';
3+
import { Stack } from '@aws-cdk/core';
34
import apigateway = require('@aws-cdk/aws-apigateway');
45
import cognito = require('@aws-cdk/aws-cognito');
56
import lambda = require('@aws-cdk/aws-lambda');

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ const api = new apigwv2.HttpApi(this, 'HttpProxyProdApi', {
204204
});
205205
```
206206

207+
To migrate a domain endpoint from one type to another, you can add a new endpoint configuration via `addEndpoint()`
208+
and then configure DNS records to route traffic to the new endpoint. After that, you can remove the previous endpoint configuration.
209+
Learn more at [Migrating a custom domain name](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-migrate.html)
210+
207211
To associate a specific `Stage` to a custom domain mapping -
208212

209213
```ts

packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
import { ICertificate } from '@aws-cdk/aws-certificatemanager';
22
import { IBucket } from '@aws-cdk/aws-s3';
3-
import { IResource, Resource, Token } from '@aws-cdk/core';
3+
import { IResource, Lazy, Resource, Token } from '@aws-cdk/core';
44
import { Construct } from 'constructs';
55
import { CfnDomainName, CfnDomainNameProps } from '../apigatewayv2.generated';
66

7+
/**
8+
* The minimum version of the SSL protocol that you want API Gateway to use for HTTPS connections.
9+
*/
10+
export enum SecurityPolicy {
11+
/** Cipher suite TLS 1.0 */
12+
TLS_1_0 = 'TLS_1_0',
13+
14+
/** Cipher suite TLS 1.2 */
15+
TLS_1_2 = 'TLS_1_2',
16+
}
17+
18+
/**
19+
* Endpoint type for a domain name.
20+
*/
21+
export enum EndpointType {
22+
/**
23+
* For an edge-optimized custom domain name.
24+
*/
25+
EDGE = 'EDGE',
26+
/**
27+
* For a regional custom domain name.
28+
*/
29+
REGIONAL = 'REGIONAL',
30+
}
31+
732
/**
833
* Represents an APIGatewayV2 DomainName
934
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html
@@ -51,20 +76,54 @@ export interface DomainNameAttributes {
5176
/**
5277
* properties used for creating the DomainName
5378
*/
54-
export interface DomainNameProps {
79+
export interface DomainNameProps extends EndpointOptions {
5580
/**
5681
* The custom domain name
5782
*/
5883
readonly domainName: string;
84+
85+
/**
86+
* The mutual TLS authentication configuration for a custom domain name.
87+
* @default - mTLS is not configured.
88+
*/
89+
readonly mtls?: MTLSConfig;
90+
}
91+
92+
/**
93+
* properties for creating a domain name endpoint
94+
*/
95+
export interface EndpointOptions {
5996
/**
60-
* The ACM certificate for this domain name
97+
* The ACM certificate for this domain name.
98+
* Certificate can be both ACM issued or imported.
6199
*/
62100
readonly certificate: ICertificate;
101+
63102
/**
64-
* The mutual TLS authentication configuration for a custom domain name.
65-
* @default - mTLS is not configured.
103+
* The user-friendly name of the certificate that will be used by the endpoint for this domain name.
104+
* @default - No friendly certificate name
105+
*/
106+
readonly certificateName?: string;
107+
108+
/**
109+
* The type of endpoint for this DomainName.
110+
* @default EndpointType.REGIONAL
111+
*/
112+
readonly endpointType?: EndpointType;
113+
114+
/**
115+
* The Transport Layer Security (TLS) version + cipher suite for this domain name.
116+
* @default SecurityPolicy.TLS_1_2
117+
*/
118+
readonly securityPolicy?: SecurityPolicy;
119+
120+
/**
121+
* A public certificate issued by ACM to validate that you own a custom domain. This parameter is required
122+
* only when you configure mutual TLS authentication and you specify an ACM imported or private CA certificate
123+
* for `certificate`. The ownership certificate validates that you have permissions to use the domain name.
124+
* @default - only required when configuring mTLS
66125
*/
67-
readonly mtls?: MTLSConfig
126+
readonly ownershipCertificate?: ICertificate;
68127
}
69128

70129
/**
@@ -107,6 +166,7 @@ export class DomainName extends Resource implements IDomainName {
107166
public readonly name: string;
108167
public readonly regionalDomainName: string;
109168
public readonly regionalHostedZoneId: string;
169+
private readonly domainNameConfigurations: CfnDomainName.DomainNameConfigurationProperty[] = [];
110170

111171
constructor(scope: Construct, id: string, props: DomainNameProps) {
112172
super(scope, id);
@@ -115,21 +175,25 @@ export class DomainName extends Resource implements IDomainName {
115175
throw new Error('empty string for domainName not allowed');
116176
}
117177

178+
// validation for ownership certificate
179+
if (props.ownershipCertificate && !props.mtls) {
180+
throw new Error('ownership certificate can only be used with mtls domains');
181+
}
182+
118183
const mtlsConfig = this.configureMTLS(props.mtls);
119184
const domainNameProps: CfnDomainNameProps = {
120185
domainName: props.domainName,
121-
domainNameConfigurations: [
122-
{
123-
certificateArn: props.certificate.certificateArn,
124-
endpointType: 'REGIONAL',
125-
},
126-
],
186+
domainNameConfigurations: Lazy.any({ produce: () => this.domainNameConfigurations }),
127187
mutualTlsAuthentication: mtlsConfig,
128188
};
129189
const resource = new CfnDomainName(this, 'Resource', domainNameProps);
130190
this.name = resource.ref;
131191
this.regionalDomainName = Token.asString(resource.getAtt('RegionalDomainName'));
132192
this.regionalHostedZoneId = Token.asString(resource.getAtt('RegionalHostedZoneId'));
193+
194+
if (props.certificate) {
195+
this.addEndpoint(props);
196+
}
133197
}
134198

135199
private configureMTLS(mtlsConfig?: MTLSConfig): CfnDomainName.MutualTlsAuthenticationProperty | undefined {
@@ -139,4 +203,30 @@ export class DomainName extends Resource implements IDomainName {
139203
truststoreVersion: mtlsConfig.version,
140204
};
141205
}
206+
207+
/**
208+
* Adds an endpoint to a domain name.
209+
* @param options domain name endpoint properties to be set
210+
*/
211+
public addEndpoint(options: EndpointOptions) : void {
212+
const domainNameConfig: CfnDomainName.DomainNameConfigurationProperty = {
213+
certificateArn: options.certificate.certificateArn,
214+
certificateName: options.certificateName,
215+
endpointType: options.endpointType ? options.endpointType?.toString() : 'REGIONAL',
216+
ownershipVerificationCertificateArn: options.ownershipCertificate?.certificateArn,
217+
securityPolicy: options.securityPolicy?.toString(),
218+
};
219+
220+
this.validateEndpointType(domainNameConfig.endpointType);
221+
this.domainNameConfigurations.push(domainNameConfig);
222+
}
223+
224+
// validates that the new domain name configuration has a unique endpoint
225+
private validateEndpointType(endpointType: string | undefined) : void {
226+
for (let config of this.domainNameConfigurations) {
227+
if (endpointType && endpointType == config.endpointType) {
228+
throw new Error(`an endpoint with type ${endpointType} already exists`);
229+
}
230+
}
231+
}
142232
}

packages/@aws-cdk/aws-apigatewayv2/test/http/domain-name.test.ts

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { Template } from '@aws-cdk/assertions';
22
import { Certificate } from '@aws-cdk/aws-certificatemanager';
33
import { Bucket } from '@aws-cdk/aws-s3';
44
import { Stack } from '@aws-cdk/core';
5-
import { DomainName, HttpApi } from '../../lib';
5+
import { DomainName, EndpointType, HttpApi, SecurityPolicy } from '../../lib';
66

77
const domainName = 'example.com';
88
const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate';
9+
const certArn2 = 'arn:aws:acm:us-east-1:111111111111:certificate2';
10+
const ownershipCertArn = 'arn:aws:acm:us-east-1:111111111111:ownershipcertificate';
911

1012
describe('DomainName', () => {
1113
test('create domain name correctly', () => {
@@ -231,4 +233,109 @@ describe('DomainName', () => {
231233
},
232234
});
233235
});
236+
237+
test('domain with mutual tls configuration and ownership cert', () => {
238+
// GIVEN
239+
const stack = new Stack();
240+
const bucket = Bucket.fromBucketName(stack, 'testBucket', 'example-bucket');
241+
242+
// WHEN
243+
new DomainName(stack, 'DomainName', {
244+
domainName,
245+
certificate: Certificate.fromCertificateArn(stack, 'cert2', certArn2),
246+
ownershipCertificate: Certificate.fromCertificateArn(stack, 'ownershipCert', ownershipCertArn),
247+
endpointType: EndpointType.REGIONAL,
248+
securityPolicy: SecurityPolicy.TLS_1_2,
249+
mtls: {
250+
bucket,
251+
key: 'someca.pem',
252+
version: 'version',
253+
},
254+
});
255+
256+
// THEN
257+
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::DomainName', {
258+
DomainName: 'example.com',
259+
DomainNameConfigurations: [
260+
{
261+
CertificateArn: 'arn:aws:acm:us-east-1:111111111111:certificate2',
262+
EndpointType: 'REGIONAL',
263+
SecurityPolicy: 'TLS_1_2',
264+
OwnershipVerificationCertificateArn: 'arn:aws:acm:us-east-1:111111111111:ownershipcertificate',
265+
},
266+
],
267+
MutualTlsAuthentication: {
268+
TruststoreUri: 's3://example-bucket/someca.pem',
269+
TruststoreVersion: 'version',
270+
},
271+
});
272+
});
273+
274+
test('throws when ownerhsip cert is used for non-mtls domain', () => {
275+
// GIVEN
276+
const stack = new Stack();
277+
278+
// WHEN
279+
const t = () => {
280+
new DomainName(stack, 'DomainName', {
281+
domainName,
282+
certificate: Certificate.fromCertificateArn(stack, 'cert2', certArn2),
283+
ownershipCertificate: Certificate.fromCertificateArn(stack, 'ownershipCert', ownershipCertArn),
284+
});
285+
};
286+
287+
// THEN
288+
expect(t).toThrow(/ownership certificate can only be used with mtls domains/);
289+
});
290+
291+
test('add new configuration to a domain name for migration', () => {
292+
// GIVEN
293+
const stack = new Stack();
294+
295+
// WHEN
296+
const dn = new DomainName(stack, 'DomainName', {
297+
domainName,
298+
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
299+
endpointType: EndpointType.REGIONAL,
300+
});
301+
dn.addEndpoint({
302+
certificate: Certificate.fromCertificateArn(stack, 'cert2', certArn2),
303+
endpointType: EndpointType.EDGE,
304+
});
305+
306+
// THEN
307+
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::DomainName', {
308+
DomainName: 'example.com',
309+
DomainNameConfigurations: [
310+
{
311+
CertificateArn: 'arn:aws:acm:us-east-1:111111111111:certificate',
312+
EndpointType: 'REGIONAL',
313+
},
314+
{
315+
CertificateArn: 'arn:aws:acm:us-east-1:111111111111:certificate2',
316+
EndpointType: 'EDGE',
317+
},
318+
],
319+
});
320+
});
321+
322+
test('throws when endpoint types for two domain name configurations are the same', () => {
323+
// GIVEN
324+
const stack = new Stack();
325+
326+
// WHEN
327+
const t = () => {
328+
const dn = new DomainName(stack, 'DomainName', {
329+
domainName,
330+
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
331+
endpointType: EndpointType.REGIONAL,
332+
});
333+
dn.addEndpoint({
334+
certificate: Certificate.fromCertificateArn(stack, 'cert2', certArn2),
335+
});
336+
};
337+
338+
// THEN
339+
expect(t).toThrow(/an endpoint with type REGIONAL already exists/);
340+
});
234341
});

packages/@aws-cdk/aws-appsync/rosetta/default.ts-fixture

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Fixture with packages imported, but nothing else
2-
import { Construct, RemovalPolicy, Stack } from '@aws-cdk/core';
2+
import { Construct } from 'constructs';
3+
import { RemovalPolicy, Stack } from '@aws-cdk/core';
34
import appsync = require('@aws-cdk/aws-appsync');
45
import ec2 = require('@aws-cdk/aws-ec2');
56
import dynamodb = require('@aws-cdk/aws-dynamodb');

packages/@aws-cdk/aws-appsync/rosetta/with-objects.ts-fixture

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Fixture with packages imported, but nothing else
2-
import { Construct, Stack } from '@aws-cdk/core';
2+
import { Construct } from 'constructs';
3+
import { Stack } from '@aws-cdk/core';
34
import appsync = require('@aws-cdk/aws-appsync');
45
const pluralize = require('pluralize');
56

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const cluster = new DatabaseCluster(this, 'Database', {
2222
masterUser: {
2323
username: 'myuser' // NOTE: 'admin' is reserved by DocumentDB
2424
excludeCharacters: '\"@/:', // optional, defaults to the set "\"@/"
25+
secretName: '/myapp/mydocdb/masteruser', // optional, if you prefer to specify the secret name
2526
},
2627
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
2728
vpcSubnets: {

packages/@aws-cdk/aws-docdb/lib/cluster.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
353353
username: props.masterUser.username,
354354
encryptionKey: props.masterUser.kmsKey,
355355
excludeCharacters: props.masterUser.excludeCharacters,
356+
secretName: props.masterUser.secretName,
356357
});
357358
}
358359

0 commit comments

Comments
 (0)