Skip to content

Commit de11488

Browse files
authored
Merge branch 'master' into DaWyz/event-bus-grant-putevents
2 parents d342bb5 + f5a6647 commit de11488

Some content is hidden

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

58 files changed

+2657
-242
lines changed

.gitallowed

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ account: '772975370895'
2222
account: '856666278305'
2323
account: '840364872350'
2424
account: '422531588944'
25+
account: '924023996002'

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export class AppMeshExtension extends ServiceExtension {
165165

166166
'me-south-1': this.accountIdForRegion('me-south-1'),
167167
'ap-east-1': this.accountIdForRegion('ap-east-1'),
168+
'af-south-1': this.accountIdForRegion('af-south-1'),
168169
},
169170
});
170171

packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json

+9
Original file line numberDiff line numberDiff line change
@@ -3354,6 +3354,9 @@
33543354
},
33553355
"ap-east-1": {
33563356
"ecrRepo": "856666278305"
3357+
},
3358+
"af-south-1": {
3359+
"ecrRepo": "924023996002"
33573360
}
33583361
},
33593362
"greetingenvoyimageaccountmapping": {
@@ -3413,6 +3416,9 @@
34133416
},
34143417
"ap-east-1": {
34153418
"ecrRepo": "856666278305"
3419+
},
3420+
"af-south-1": {
3421+
"ecrRepo": "924023996002"
34163422
}
34173423
},
34183424
"greeterenvoyimageaccountmapping": {
@@ -3472,6 +3478,9 @@
34723478
},
34733479
"ap-east-1": {
34743480
"ecrRepo": "856666278305"
3481+
},
3482+
"af-south-1": {
3483+
"ecrRepo": "924023996002"
34753484
}
34763485
}
34773486
},

packages/@aws-cdk-containers/ecs-service-extensions/test/integ.multiple-environments.expected.json

+6
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,9 @@
21732173
},
21742174
"ap-east-1": {
21752175
"ecrRepo": "856666278305"
2176+
},
2177+
"af-south-1": {
2178+
"ecrRepo": "924023996002"
21762179
}
21772180
},
21782181
"namedevelopmentenvoyimageaccountmapping": {
@@ -2232,6 +2235,9 @@
22322235
},
22332236
"ap-east-1": {
22342237
"ecrRepo": "856666278305"
2238+
},
2239+
"af-south-1": {
2240+
"ecrRepo": "924023996002"
22352241
}
22362242
}
22372243
}

packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ export class CacheHeaderBehavior {
231231
if (headers.length === 0) {
232232
throw new Error('At least one header to allow must be provided');
233233
}
234+
if (headers.length > 10) {
235+
throw new Error(`Maximum allowed headers in Cache Policy is 10; got ${headers.length}.`);
236+
}
234237
return new CacheHeaderBehavior('whitelist', headers);
235238
}
236239

packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ describe('CachePolicy', () => {
9696
expect(() => new CachePolicy(stack, 'CachePolicy6', { cachePolicyName: 'My_Policy' })).not.toThrow();
9797
});
9898

99+
test('throws if more than 10 CacheHeaderBehavior headers are being passed', () => {
100+
const errorMessage = /Maximum allowed headers in Cache Policy is 10; got (.*?)/;
101+
expect(() => new CachePolicy(stack, 'CachePolicy1', {
102+
headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do', 'eiusmod'),
103+
})).toThrow(errorMessage);
104+
105+
expect(() => new CachePolicy(stack, 'CachePolicy2', {
106+
headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do'),
107+
})).not.toThrow();
108+
});
109+
99110
test('does not throw if cachePolicyName is a token', () => {
100111
expect(() => new CachePolicy(stack, 'CachePolicy', {
101112
cachePolicyName: Aws.STACK_NAME,

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

+28
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,31 @@ if (project.enableBatchBuilds()) {
617617
console.log('Batch builds were enabled');
618618
}
619619
```
620+
621+
## Timeouts
622+
623+
There are two types of timeouts that can be set when creating your Project.
624+
The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed.
625+
The default is 60 minutes.
626+
An example of overriding the default follows.
627+
628+
```ts
629+
import * as codebuild from '@aws-cdk/aws-codebuild';
630+
631+
new codebuild.Project(stack, 'MyProject', {
632+
timeout: Duration.minutes(90)
633+
});
634+
```
635+
636+
The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run.
637+
There is no default value for this property.
638+
As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails,
639+
use the following code.
640+
641+
```ts
642+
import * as codebuild from '@aws-cdk/aws-codebuild';
643+
644+
new codebuild.Project(stack, 'MyProject', {
645+
queuedTimeout: Duration.minutes(30)
646+
});
647+
```

packages/@aws-cdk/aws-codebuild/lib/project.ts

+10
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,15 @@ export interface CommonProjectProps {
575575
* @default - no log configuration is set
576576
*/
577577
readonly logging?: LoggingOptions;
578+
579+
/**
580+
* The number of minutes after which AWS CodeBuild stops the build if it's
581+
* still in queue. For valid values, see the timeoutInMinutes field in the AWS
582+
* CodeBuild User Guide.
583+
*
584+
* @default - no queue timeout is set
585+
*/
586+
readonly queuedTimeout?: Duration
578587
}
579588

580589
export interface ProjectProps extends CommonProjectProps {
@@ -869,6 +878,7 @@ export class Project extends ProjectBase {
869878
cache: cache._toCloudFormation(),
870879
name: this.physicalName,
871880
timeoutInMinutes: props.timeout && props.timeout.toMinutes(),
881+
queuedTimeoutInMinutes: props.queuedTimeout && props.queuedTimeout.toMinutes(),
872882
secondarySources: Lazy.any({ produce: () => this.renderSecondarySources() }),
873883
secondarySourceVersions: Lazy.any({ produce: () => this.renderSecondarySourceVersions() }),
874884
secondaryArtifacts: Lazy.any({ produce: () => this.renderSecondaryArtifacts() }),

packages/@aws-cdk/aws-codebuild/test/test.project.ts

+43
Original file line numberDiff line numberDiff line change
@@ -960,4 +960,47 @@ export = {
960960
test.done();
961961
},
962962
},
963+
964+
'Timeouts': {
965+
'can add queued timeout'(test: Test) {
966+
// GIVEN
967+
const stack = new cdk.Stack();
968+
969+
// WHEN
970+
new codebuild.Project(stack, 'Project', {
971+
source: codebuild.Source.s3({
972+
bucket: new s3.Bucket(stack, 'Bucket'),
973+
path: 'path',
974+
}),
975+
queuedTimeout: cdk.Duration.minutes(30),
976+
});
977+
978+
// THEN
979+
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
980+
QueuedTimeoutInMinutes: 30,
981+
}));
982+
983+
test.done();
984+
},
985+
'can override build timeout'(test: Test) {
986+
// GIVEN
987+
const stack = new cdk.Stack();
988+
989+
// WHEN
990+
new codebuild.Project(stack, 'Project', {
991+
source: codebuild.Source.s3({
992+
bucket: new s3.Bucket(stack, 'Bucket'),
993+
path: 'path',
994+
}),
995+
timeout: cdk.Duration.minutes(30),
996+
});
997+
998+
// THEN
999+
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
1000+
TimeoutInMinutes: 30,
1001+
}));
1002+
1003+
test.done();
1004+
},
1005+
},
9631006
};

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
238238
public readonly clusterResourceIdentifier: string;
239239

240240
/**
241-
* The connections object to implement IConectable
241+
* The connections object to implement IConnectable
242242
*/
243243
public readonly connections: ec2.Connections;
244244

packages/@aws-cdk/aws-dynamodb-global/lib/global-table-coordinator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class GlobalTableCoordinator extends cdk.Stack {
1919
code: lambda.Code.fromAsset(path.resolve(__dirname, '../', 'lambda-packages', 'aws-global-table-coordinator', 'lib')),
2020
description: 'Lambda to make DynamoDB a global table',
2121
handler: 'index.handler',
22-
runtime: lambda.Runtime.NODEJS_10_X,
22+
runtime: lambda.Runtime.NODEJS_14_X,
2323
timeout: cdk.Duration.minutes(5),
2424
uuid: 'D38B65A6-6B54-4FB6-9BAD-9CD40A6DAC12',
2525
});

packages/@aws-cdk/aws-dynamodb-global/test/integ.dynamodb.global.expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
"Arn"
204204
]
205205
},
206-
"Runtime": "nodejs10.x",
206+
"Runtime": "nodejs14.x",
207207
"Description": "Lambda to make DynamoDB a global table",
208208
"Timeout": 300
209209
},

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

+11
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ globalTable.autoScaleWriteCapacity({
109109
}).scaleOnUtilization({ targetUtilizationPercent: 75 });
110110
```
111111

112+
When adding a replica region for a large table, you might want to increase the
113+
timeout for the replication operation:
114+
115+
```ts
116+
const globalTable = new dynamodb.Table(this, 'Table', {
117+
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
118+
replicationRegions: ['us-east-1', 'us-east-2', 'us-west-2'],
119+
replicationTimeout: Duration.hours(2), // defaults to Duration.minutes(30)
120+
});
121+
```
122+
112123
## Encryption
113124

114125
All user data stored in Amazon DynamoDB is fully encrypted at rest. When creating a new table, you can choose to encrypt using the following customer master keys (CMK) to encrypt your table:

packages/@aws-cdk/aws-dynamodb/lib/replica-provider.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,26 @@ import { Construct } from 'constructs';
99
// eslint-disable-next-line no-duplicate-imports, import/order
1010
import { Construct as CoreConstruct } from '@aws-cdk/core';
1111

12+
/**
13+
* Properties for a ReplicaProvider
14+
*/
15+
export interface ReplicaProviderProps {
16+
/**
17+
* The timeout for the replication operation.
18+
*
19+
* @default Duration.minutes(30)
20+
*/
21+
readonly timeout?: Duration;
22+
}
23+
1224
export class ReplicaProvider extends NestedStack {
1325
/**
1426
* Creates a stack-singleton resource provider nested stack.
1527
*/
16-
public static getOrCreate(scope: Construct) {
28+
public static getOrCreate(scope: Construct, props: ReplicaProviderProps = {}) {
1729
const stack = Stack.of(scope);
1830
const uid = '@aws-cdk/aws-dynamodb.ReplicaProvider';
19-
return stack.node.tryFindChild(uid) as ReplicaProvider || new ReplicaProvider(stack, uid);
31+
return stack.node.tryFindChild(uid) as ReplicaProvider ?? new ReplicaProvider(stack, uid, props);
2032
}
2133

2234
/**
@@ -34,7 +46,7 @@ export class ReplicaProvider extends NestedStack {
3446
*/
3547
public readonly isCompleteHandler: lambda.Function;
3648

37-
private constructor(scope: Construct, id: string) {
49+
private constructor(scope: Construct, id: string, props: ReplicaProviderProps = {}) {
3850
super(scope as CoreConstruct, id);
3951

4052
const code = lambda.Code.fromAsset(path.join(__dirname, 'replica-handler'));
@@ -80,6 +92,7 @@ export class ReplicaProvider extends NestedStack {
8092
onEventHandler: this.onEventHandler,
8193
isCompleteHandler: this.isCompleteHandler,
8294
queryInterval: Duration.seconds(10),
95+
totalTimeout: props.timeout,
8396
});
8497
}
8598
}

packages/@aws-cdk/aws-dynamodb/lib/table.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
33
import * as iam from '@aws-cdk/aws-iam';
44
import * as kms from '@aws-cdk/aws-kms';
55
import {
6-
Aws, CfnCondition, CfnCustomResource, CustomResource, Fn,
7-
IResource, Lazy, Names, RemovalPolicy, Resource, Stack, Token,
6+
Aws, CfnCondition, CfnCustomResource, CustomResource, Duration,
7+
Fn, IResource, Lazy, Names, RemovalPolicy, Resource, Stack, Token,
88
} from '@aws-cdk/core';
99
import { Construct } from 'constructs';
1010
import { DynamoDBMetrics } from './dynamodb-canned-metrics.generated';
@@ -218,6 +218,13 @@ export interface TableOptions {
218218
* @experimental
219219
*/
220220
readonly replicationRegions?: string[];
221+
222+
/**
223+
* The timeout for a table replication operation in a single region.
224+
*
225+
* @default Duration.minutes(30)
226+
*/
227+
readonly replicationTimeout?: Duration;
221228
}
222229

223230
/**
@@ -1135,7 +1142,7 @@ export class Table extends TableBase {
11351142
}
11361143

11371144
if (props.replicationRegions && props.replicationRegions.length > 0) {
1138-
this.createReplicaTables(props.replicationRegions);
1145+
this.createReplicaTables(props.replicationRegions, props.replicationTimeout);
11391146
}
11401147
}
11411148

@@ -1451,14 +1458,14 @@ export class Table extends TableBase {
14511458
*
14521459
* @param regions regions where to create tables
14531460
*/
1454-
private createReplicaTables(regions: string[]) {
1461+
private createReplicaTables(regions: string[], timeout?: Duration) {
14551462
const stack = Stack.of(this);
14561463

14571464
if (!Token.isUnresolved(stack.region) && regions.includes(stack.region)) {
14581465
throw new Error('`replicationRegions` cannot include the region where this stack is deployed.');
14591466
}
14601467

1461-
const provider = ReplicaProvider.getOrCreate(this);
1468+
const provider = ReplicaProvider.getOrCreate(this, { timeout });
14621469

14631470
// Documentation at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2gt_IAM.html
14641471
// is currently incorrect. AWS Support recommends `dynamodb:*` in both source and destination regions

0 commit comments

Comments
 (0)