Skip to content

Commit 76c5918

Browse files
authored
Merge branch 'master' into shivlaks/sfn-merge-task-and-state-lambda
2 parents 6e695a8 + 1bfe70a commit 76c5918

29 files changed

+628
-11
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
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.40.0](https://github.com/aws/aws-cdk/compare/v1.39.0...v1.40.0) (2020-05-20)
6+
7+
8+
### Features
9+
10+
* add support for Gitpod workspaces ([20d5511](https://github.com/aws/aws-cdk/commit/20d551142ea13c57981ad8b24ac61d03091da6b9))
11+
* **autoscaling:** support max instance lifetime ([d126c46](https://github.com/aws/aws-cdk/commit/d126c46f8429b30e1937e2e970011bc6fac8b5a2)), closes [#7758](https://github.com/aws/aws-cdk/issues/7758)
12+
* **cfn-include:** add support for the DependsOn attribute ([613df1b](https://github.com/aws/aws-cdk/commit/613df1b8e4b794a772d6124a22463072617aef62))
13+
* **docdb:** high level constrcuts for db clusters and instances ([#6511](https://github.com/aws/aws-cdk/issues/6511)) ([a376dd3](https://github.com/aws/aws-cdk/commit/a376dd326e180462044b610c6925998482bd04d2))
14+
* **eks:** IAM roles for service accounts ([3f0d2c8](https://github.com/aws/aws-cdk/commit/3f0d2c82ef6102fb6b8cea23e397f559fa6a4d61)), closes [#6062](https://github.com/aws/aws-cdk/issues/6062) [#5388](https://github.com/aws/aws-cdk/issues/5388) [#3949](https://github.com/aws/aws-cdk/issues/3949)
15+
* **elbv2:** full Action support ([2939105](https://github.com/aws/aws-cdk/commit/29391059a571fc41d94275f36cf54e08c6f5441f)), closes [#2563](https://github.com/aws/aws-cdk/issues/2563) [#6310](https://github.com/aws/aws-cdk/issues/6310) [#6308](https://github.com/aws/aws-cdk/issues/6308)
16+
* **region-info:** add information for us-gov, us-iso, and us-isob regions ([afe0b00](https://github.com/aws/aws-cdk/commit/afe0b00b12afe383da49dcfa07f85b578728a0d1)), closes [#7876](https://github.com/aws/aws-cdk/issues/7876) [#4669](https://github.com/aws/aws-cdk/issues/4669)
17+
* **s3-asset:** add httpUrl and s3ObjectUrl ([eeff393](https://github.com/aws/aws-cdk/commit/eeff39324e4735096f85b32d37c95011881467b6)), closes [#7509](https://github.com/aws/aws-cdk/issues/7509) [#7221](https://github.com/aws/aws-cdk/issues/7221)
18+
519
## [1.39.0](https://github.com/aws/aws-cdk/compare/v1.38.0...v1.39.0) (2020-05-15)
620

721

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[![PyPI version](https://badge.fury.io/py/aws-cdk.core.svg)](https://badge.fury.io/py/aws-cdk.core)
88
[![NuGet version](https://badge.fury.io/nu/Amazon.CDK.svg)](https://badge.fury.io/nu/Amazon.CDK)
99
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/software.amazon.awscdk/core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/software.amazon.awscdk/core)
10+
[![Mergify](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/aws/aws-cdk&style=flat)](https://mergify.io)
1011

1112
The **AWS Cloud Development Kit (AWS CDK)** is an open-source software development
1213
framework to define cloud infrastructure in code and provision it through AWS CloudFormation.

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.39.0"
13+
"version": "1.40.0"
1414
}

packages/@aws-cdk/aws-apigateway/lib/access-log.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class AccessLogField {
4646
* The API owner's AWS account ID.
4747
*/
4848
public static contextAccountId() {
49-
return '$context.requestId';
49+
return '$context.identity.accountId';
5050
}
5151

5252
/**

packages/@aws-cdk/aws-apigateway/test/test.access-log.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export = {
3838
requestId: apigateway.AccessLogField.contextRequestId(),
3939
sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
4040
method: apigateway.AccessLogField.contextHttpMethod(),
41+
accountId: apigateway.AccessLogField.contextAccountId(),
4142
userContext: {
4243
sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
4344
email: apigateway.AccessLogField.contextAuthorizerClaims('email'),
4445
},
4546
}));
46-
test.deepEqual(testFormat.toString(), '{"requestId":"$context.requestId","sourceIp":"$context.identity.sourceIp","method":"$context.httpMethod","userContext":{"sub":"$context.authorizer.claims.sub","email":"$context.authorizer.claims.email"}}');
47+
test.deepEqual(testFormat.toString(), '{"requestId":"$context.requestId","sourceIp":"$context.identity.sourceIp","method":"$context.httpMethod","accountId":"$context.identity.accountId","userContext":{"sub":"$context.authorizer.claims.sub","email":"$context.authorizer.claims.email"}}');
4748

4849
test.done();
4950
},

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

+8
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ autoScalingGroup.scaleOnSchedule('AllowDownscalingAtNight', {
218218
See the documentation of the `@aws-cdk/aws-ec2` package for more information
219219
about allowing connections between resources backed by instances.
220220

221+
### Max Instance Lifetime
222+
223+
To enable the max instance lifetime support, specify `maxInstanceLifetime` property
224+
for the `AutoscalingGroup` resource. The value must be between 7 and 365 days(inclusive).
225+
To clear a previously set value, just leave this property undefinied.
226+
227+
228+
221229
### Future work
222230

223231
- [ ] CloudWatch Events (impossible to add currently as the AutoScalingGroup ARN is

packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts

+26
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ export interface CommonAutoScalingGroupProps {
185185
* @default - Uses the block device mapping of the AMI
186186
*/
187187
readonly blockDevices?: BlockDevice[];
188+
189+
/**
190+
* The maximum amount of time that an instance can be in service. The maximum duration applies
191+
* to all current and future instances in the group. As an instance approaches its maximum duration,
192+
* it is terminated and replaced, and cannot be used again.
193+
*
194+
* You must specify a value of at least 604,800 seconds (7 days). To clear a previously set value,
195+
* simply leave this property undefinied.
196+
*
197+
* @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-max-instance-lifetime.html
198+
*
199+
* @default none
200+
*/
201+
readonly maxInstanceLifetime?: Duration;
188202
}
189203

190204
/**
@@ -411,6 +425,11 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
411425
*/
412426
public readonly spotPrice?: string;
413427

428+
/**
429+
* The maximum amount of time that an instance can be in service.
430+
*/
431+
public readonly maxInstanceLifetime?: Duration;
432+
414433
private readonly autoScalingGroup: CfnAutoScalingGroup;
415434
private readonly securityGroup: ec2.ISecurityGroup;
416435
private readonly securityGroups: ec2.ISecurityGroup[] = [];
@@ -492,6 +511,12 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
492511
this.node.addWarning('desiredCapacity has been configured. Be aware this will reset the size of your AutoScalingGroup on every deployment. See https://github.com/aws/aws-cdk/issues/5215');
493512
}
494513

514+
this.maxInstanceLifetime = props.maxInstanceLifetime;
515+
if (this.maxInstanceLifetime &&
516+
(this.maxInstanceLifetime.toSeconds() < 604800 || this.maxInstanceLifetime.toSeconds() > 31536000)) {
517+
throw new Error('maxInstanceLifetime must be between 7 and 365 days (inclusive)');
518+
}
519+
495520
const { subnetIds, hasPublic } = props.vpc.selectSubnets(props.vpcSubnets);
496521
const asgProps: CfnAutoScalingGroupProps = {
497522
cooldown: props.cooldown !== undefined ? props.cooldown.toSeconds().toString() : undefined,
@@ -515,6 +540,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
515540
vpcZoneIdentifier: subnetIds,
516541
healthCheckType: props.healthCheck && props.healthCheck.type,
517542
healthCheckGracePeriod: props.healthCheck && props.healthCheck.gracePeriod && props.healthCheck.gracePeriod.toSeconds(),
543+
maxInstanceLifetime: this.maxInstanceLifetime ? this.maxInstanceLifetime.toSeconds() : undefined,
518544
};
519545

520546
if (!hasPublic && props.associatePublicIpAddress) {

packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.expected.json

+1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@
454454
"LaunchConfigurationName": {
455455
"Ref": "FleetLaunchConfig59F79D36"
456456
},
457+
"MaxInstanceLifetime": 604800,
457458
"Tags": [
458459
{
459460
"Key": "Name",

packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ new autoscaling.AutoScalingGroup(stack, 'Fleet', {
1414
vpc,
1515
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
1616
machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 }),
17+
maxInstanceLifetime: cdk.Duration.days(7),
1718
});
1819

1920
app.synth();

packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts

+55
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,61 @@ export = {
761761
test.done();
762762
},
763763

764+
'can configure maxInstanceLifetime'(test: Test) {
765+
// GIVEN
766+
const stack = new cdk.Stack();
767+
const vpc = mockVpc(stack);
768+
new autoscaling.AutoScalingGroup(stack, 'MyStack', {
769+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO),
770+
machineImage: new ec2.AmazonLinuxImage(),
771+
vpc,
772+
maxInstanceLifetime: cdk.Duration.days(7),
773+
});
774+
775+
// THEN
776+
expect(stack).to(haveResource('AWS::AutoScaling::AutoScalingGroup', {
777+
'MaxInstanceLifetime': 604800,
778+
}));
779+
780+
test.done();
781+
},
782+
783+
'throws if maxInstanceLifetime < 7 days'(test: Test) {
784+
// GIVEN
785+
const stack = new cdk.Stack();
786+
const vpc = mockVpc(stack);
787+
788+
// THEN
789+
test.throws(() => {
790+
new autoscaling.AutoScalingGroup(stack, 'MyStack', {
791+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO),
792+
machineImage: new ec2.AmazonLinuxImage(),
793+
vpc,
794+
maxInstanceLifetime: cdk.Duration.days(6),
795+
});
796+
}, /maxInstanceLifetime must be between 7 and 365 days \(inclusive\)/);
797+
798+
test.done();
799+
},
800+
801+
'throws if maxInstanceLifetime > 365 days'(test: Test) {
802+
// GIVEN
803+
const stack = new cdk.Stack();
804+
const vpc = mockVpc(stack);
805+
806+
// THEN
807+
test.throws(() => {
808+
new autoscaling.AutoScalingGroup(stack, 'MyStack', {
809+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO),
810+
machineImage: new ec2.AmazonLinuxImage(),
811+
vpc,
812+
maxInstanceLifetime: cdk.Duration.days(366),
813+
});
814+
}, /maxInstanceLifetime must be between 7 and 365 days \(inclusive\)/);
815+
816+
test.done();
817+
},
818+
764819
'throws if ephemeral volumeIndex < 0'(test: Test) {
765820
// GIVEN
766821
const stack = new cdk.Stack();

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

+3
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ new UserPool(this, 'myuserpool', {
148148
});
149149
```
150150

151+
A user pool can optionally ignore case when evaluating sign-ins. When `signInCaseSensitive` is false, Cognito will not
152+
check the capitalization of the alias when signing in. Default is true.
153+
151154
### Attributes
152155

153156
Attributes represent the various properties of each user that's collected and stored in the user pool. Cognito

packages/@aws-cdk/aws-cognito/lib/user-pool.ts

+10
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ export interface UserPoolProps {
500500
* @default - No Lambda triggers.
501501
*/
502502
readonly lambdaTriggers?: UserPoolTriggers;
503+
504+
/**
505+
* Whether sign-in aliases should be evaluated with case sensitivity.
506+
* For example, when this option is set to false, users will be able to sign in using either `MyUsername` or `myusername`.
507+
* @default true
508+
*/
509+
readonly signInCaseSensitive?: boolean;
503510
}
504511

505512
/**
@@ -637,6 +644,9 @@ export class UserPool extends Resource implements IUserPool {
637644
from: props.emailSettings?.from,
638645
replyToEmailAddress: props.emailSettings?.replyTo,
639646
}),
647+
usernameConfiguration: undefinedIfNoKeys({
648+
caseSensitive: props.signInCaseSensitive,
649+
}),
640650
});
641651

642652
this.userPoolId = userPool.ref;

packages/@aws-cdk/aws-cognito/test/user-pool.test.ts

+30
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,36 @@ describe('User Pool', () => {
454454
});
455455
});
456456

457+
test('sign in case sensitive is correctly picked up', () => {
458+
// GIVEN
459+
const stack = new Stack();
460+
461+
// WHEN
462+
new UserPool(stack, 'Pool', {
463+
signInCaseSensitive: false,
464+
});
465+
466+
// THEN
467+
expect(stack).toHaveResourceLike('AWS::Cognito::UserPool', {
468+
UsernameConfiguration: {
469+
CaseSensitive: false,
470+
},
471+
});
472+
});
473+
474+
test('sign in case sensitive is absent by default', () => {
475+
// GIVEN
476+
const stack = new Stack();
477+
478+
// WHEN
479+
new UserPool(stack, 'Pool', {});
480+
481+
// THEN
482+
expect(stack).toHaveResourceLike('AWS::Cognito::UserPool', {
483+
UsernameConfiguration: ABSENT,
484+
});
485+
});
486+
457487
test('required attributes', () => {
458488
// GIVEN
459489
const stack = new Stack();

packages/@aws-cdk/aws-sns-subscriptions/lib/email.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class EmailSubscription implements sns.ITopicSubscription {
3232
endpoint: this.emailAddress,
3333
protocol: this.props.json ? sns.SubscriptionProtocol.EMAIL_JSON : sns.SubscriptionProtocol.EMAIL,
3434
filterPolicy: this.props.filterPolicy,
35+
deadLetterQueue: this.props.deadLetterQueue,
3536
};
3637
}
3738
}

packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class LambdaSubscription implements sns.ITopicSubscription {
3939
protocol: sns.SubscriptionProtocol.LAMBDA,
4040
filterPolicy: this.props.filterPolicy,
4141
region: this.regionFromArn(topic),
42+
deadLetterQueue: this.props.deadLetterQueue,
4243
};
4344
}
4445

packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class SqsSubscription implements sns.ITopicSubscription {
5454
rawMessageDelivery: this.props.rawMessageDelivery,
5555
filterPolicy: this.props.filterPolicy,
5656
region: this.regionFromArn(topic),
57+
deadLetterQueue: this.props.deadLetterQueue,
5758
};
5859
}
5960

packages/@aws-cdk/aws-sns-subscriptions/lib/subscription.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as sns from '@aws-cdk/aws-sns';
2+
import { IQueue } from '@aws-cdk/aws-sqs';
23

34
/**
45
* Options to subscribing to an SNS topic
@@ -10,4 +11,12 @@ export interface SubscriptionProps {
1011
* @default - all messages are delivered
1112
*/
1213
readonly filterPolicy?: { [attribute: string]: sns.SubscriptionFilter };
14+
15+
/**
16+
* Queue to be used as dead letter queue.
17+
* If not passed no dead letter queue is enabled.
18+
*
19+
* @default - No dead letter queue enabled.
20+
*/
21+
readonly deadLetterQueue?: IQueue;
1322
}

packages/@aws-cdk/aws-sns-subscriptions/lib/url.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class UrlSubscription implements sns.ITopicSubscription {
6161
protocol: this.protocol,
6262
rawMessageDelivery: this.props.rawMessageDelivery,
6363
filterPolicy: this.props.filterPolicy,
64+
deadLetterQueue: this.props.deadLetterQueue,
6465
};
6566
}
6667
}

packages/@aws-cdk/aws-sns-subscriptions/test/integ.sns-lambda.expected.json

+48
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,57 @@
8181
"Echo11F3FB29",
8282
"Arn"
8383
]
84+
},
85+
"RedrivePolicy": {
86+
"deadLetterTargetArn": {
87+
"Fn::GetAtt": [
88+
"DeadLetterQueue9F481546",
89+
"Arn"
90+
]
91+
}
8492
}
8593
}
8694
},
95+
"DeadLetterQueue9F481546": {
96+
"Type": "AWS::SQS::Queue",
97+
"Properties": {
98+
}
99+
},
100+
"DeadLetterQueuePolicyB1FB890C": {
101+
"Type": "AWS::SQS::QueuePolicy",
102+
"Properties": {
103+
"PolicyDocument": {
104+
"Statement": [
105+
{
106+
"Action": "sqs:SendMessage",
107+
"Condition": {
108+
"ArnEquals": {
109+
"aws:SourceArn": {
110+
"Ref": "MyTopic86869434"
111+
}
112+
}
113+
},
114+
"Effect": "Allow",
115+
"Principal": {
116+
"Service": "sns.amazonaws.com"
117+
},
118+
"Resource": {
119+
"Fn::GetAtt": [
120+
"DeadLetterQueue9F481546",
121+
"Arn"
122+
]
123+
}
124+
}
125+
],
126+
"Version": "2012-10-17"
127+
},
128+
"Queues": [
129+
{
130+
"Ref": "DeadLetterQueue9F481546"
131+
}
132+
]
133+
}
134+
},
87135
"FilteredServiceRole16D9DDC1": {
88136
"Type": "AWS::IAM::Role",
89137
"Properties": {

0 commit comments

Comments
 (0)