Skip to content

Commit 781bbde

Browse files
committed
Merge branch 'master' into v2/forward-merge-20220322
2 parents 43b9c85 + a349666 commit 781bbde

File tree

97 files changed

+3671
-571
lines changed

Some content is hidden

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

97 files changed

+3671
-571
lines changed

.github/workflows/pr-labeler.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
name: pr-labeler
44
on:
55
pull_request:
6-
types: [ opened ]
6+
types:
7+
- opened
8+
- edited
9+
- reopened
710

811
jobs:
912
auto-approve:
@@ -13,6 +16,16 @@ jobs:
1316
pull-requests: write
1417
issues: write
1518
steps:
16-
- run: gh pr edit ${{ github.event.pull_request.number }} --add-label "auto-approve" -R ${{ github.repository }}
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
- run: gh pr edit ${{ github.event.pull_request.number }} --add-label "auto-approve" -R ${{ github.repository }}
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
copy-labels:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
pull-requests: write
26+
steps:
27+
- uses: kaizen3031593/pr-triage-manager@main
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"fs-extra": "^9.1.0",
2323
"graceful-fs": "^4.2.9",
2424
"jest-junit": "^13.0.0",
25-
"jsii-diff": "^1.55.0",
26-
"jsii-pacmak": "^1.55.0",
27-
"jsii-reflect": "^1.55.0",
28-
"jsii-rosetta": "^1.55.0",
25+
"jsii-diff": "^1.55.1",
26+
"jsii-pacmak": "^1.55.1",
27+
"jsii-reflect": "^1.55.1",
28+
"jsii-rosetta": "^1.55.1",
2929
"lerna": "^4.0.0",
3030
"patch-package": "^6.4.7",
3131
"semver": "^6.3.0",

packages/@aws-cdk-containers/ecs-service-extensions/test/integ.assign-public-ip.expected.json

+22-6
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,28 @@
10511051
{
10521052
"Action": "lambda:InvokeFunction",
10531053
"Effect": "Allow",
1054-
"Resource": {
1055-
"Fn::GetAtt": [
1056-
"nameserviceTaskRecordManagerCleanupResourceProviderHandler08068F99",
1057-
"Arn"
1058-
]
1059-
}
1054+
"Resource": [
1055+
{
1056+
"Fn::GetAtt": [
1057+
"nameserviceTaskRecordManagerCleanupResourceProviderHandler08068F99",
1058+
"Arn"
1059+
]
1060+
},
1061+
{
1062+
"Fn::Join": [
1063+
"",
1064+
[
1065+
{
1066+
"Fn::GetAtt": [
1067+
"nameserviceTaskRecordManagerCleanupResourceProviderHandler08068F99",
1068+
"Arn"
1069+
]
1070+
},
1071+
":*"
1072+
]
1073+
]
1074+
}
1075+
]
10601076
}
10611077
],
10621078
"Version": "2012-10-17"

packages/@aws-cdk/app-delivery/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@aws-cdk/cdk-integ-tools": "0.0.0",
7575
"@aws-cdk/pkglint": "0.0.0",
7676
"@types/jest": "^27.4.1",
77-
"fast-check": "^2.23.0",
77+
"fast-check": "^2.23.2",
7878
"jest": "^27.5.1"
7979
},
8080
"repository": {

packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
105105
this.role.attachInlinePolicy(new iam.Policy(this, 'authorizerInvokePolicy', {
106106
statements: [
107107
new iam.PolicyStatement({
108-
resources: [this.handler.functionArn],
108+
resources: this.handler.resourceArnsForGrantInvoke,
109109
actions: ['lambda:InvokeFunction'],
110110
}),
111111
],

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json

+22-6
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,28 @@
176176
{
177177
"Action": "lambda:InvokeFunction",
178178
"Effect": "Allow",
179-
"Resource": {
180-
"Fn::GetAtt": [
181-
"MyAuthorizerFunction70F1223E",
182-
"Arn"
183-
]
184-
}
179+
"Resource": [
180+
{
181+
"Fn::GetAtt": [
182+
"MyAuthorizerFunction70F1223E",
183+
"Arn"
184+
]
185+
},
186+
{
187+
"Fn::Join": [
188+
"",
189+
[
190+
{
191+
"Fn::GetAtt": [
192+
"MyAuthorizerFunction70F1223E",
193+
"Arn"
194+
]
195+
},
196+
":*"
197+
]
198+
]
199+
}
200+
]
185201
}
186202
],
187203
"Version": "2012-10-17"

packages/@aws-cdk/aws-apigateway/test/authorizers/lambda.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ describe('lambda authorizer', () => {
393393
PolicyDocument: {
394394
Statement: [
395395
{
396-
Resource: stack.resolve(func.functionArn),
396+
Resource: stack.resolve(func.resourceArnsForGrantInvoke),
397397
Action: 'lambda:InvokeFunction',
398398
Effect: 'Allow',
399399
},
@@ -485,7 +485,7 @@ describe('lambda authorizer', () => {
485485
PolicyDocument: {
486486
Statement: [
487487
{
488-
Resource: stack.resolve(func.functionArn),
488+
Resource: stack.resolve(func.resourceArnsForGrantInvoke),
489489
Action: 'lambda:InvokeFunction',
490490
Effect: 'Allow',
491491
},

packages/@aws-cdk/aws-applicationautoscaling/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@aws-cdk/cfn2ts": "0.0.0",
8686
"@aws-cdk/pkglint": "0.0.0",
8787
"@types/jest": "^27.4.1",
88-
"fast-check": "^2.23.0",
88+
"fast-check": "^2.23.2",
8989
"jest": "^27.5.1"
9090
},
9191
"dependencies": {

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

+22-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,28 @@
5858
{
5959
"Action": "lambda:InvokeFunction",
6060
"Effect": "Allow",
61-
"Resource": {
62-
"Fn::GetAtt": [
63-
"funcC3A0C2E2",
64-
"Arn"
65-
]
66-
}
61+
"Resource": [
62+
{
63+
"Fn::GetAtt": [
64+
"funcC3A0C2E2",
65+
"Arn"
66+
]
67+
},
68+
{
69+
"Fn::Join": [
70+
"",
71+
[
72+
{
73+
"Fn::GetAtt": [
74+
"funcC3A0C2E2",
75+
"Arn"
76+
]
77+
},
78+
":*"
79+
]
80+
]
81+
}
82+
]
6783
}
6884
],
6985
"Version": "2012-10-17"

packages/@aws-cdk/aws-autoscaling-common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"@aws-cdk/cdk-integ-tools": "0.0.0",
7777
"@aws-cdk/pkglint": "0.0.0",
7878
"@types/jest": "^27.4.1",
79-
"fast-check": "^2.23.0",
79+
"fast-check": "^2.23.2",
8080
"jest": "^27.5.1"
8181
},
8282
"dependencies": {

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

+21
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,27 @@ const aspect = new autoscaling.AutoScalingGroupRequireImdsv2Aspect();
488488
Aspects.of(this).add(aspect);
489489
```
490490

491+
## Warm Pool
492+
493+
Auto Scaling offers [a warm pool](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-warm-pools.html) which gives an ability to decrease latency for applications that have exceptionally long boot times. You can create a warm pool with default parameters as below:
494+
495+
```ts
496+
declare const autoScalingGroup: autoscaling.AutoScalingGroup;
497+
498+
autoScalingGroup.addWarmPool();
499+
```
500+
501+
You can also customize a warm pool by configuring parameters:
502+
503+
```ts
504+
declare const autoScalingGroup: autoscaling.AutoScalingGroup;
505+
506+
autoScalingGroup.addWarmPool({
507+
minSize: 1,
508+
reuseOnScaleIn: true,
509+
});
510+
```
511+
491512
## Future work
492513

493514
* [ ] CloudWatch Events (impossible to add currently as the AutoScalingGroup ARN is

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

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { BasicStepScalingPolicyProps, StepScalingPolicy } from './step-scaling-p
2323
import { BaseTargetTrackingProps, PredefinedMetric, TargetTrackingScalingPolicy } from './target-tracking-scaling-policy';
2424
import { TerminationPolicy } from './termination-policy';
2525
import { BlockDevice, BlockDeviceVolume, EbsDeviceVolumeType } from './volume';
26+
import { WarmPool, WarmPoolOptions } from './warm-pool';
2627

2728
/**
2829
* Name tag constant
@@ -744,6 +745,16 @@ abstract class AutoScalingGroupBase extends Resource implements IAutoScalingGrou
744745
});
745746
}
746747

748+
/**
749+
* Add a pool of pre-initialized EC2 instances that sits alongside an Auto Scaling group
750+
*/
751+
public addWarmPool(options?: WarmPoolOptions): WarmPool {
752+
return new WarmPool(this, 'WarmPool', {
753+
autoScalingGroup: this,
754+
...options,
755+
});
756+
}
757+
747758
/**
748759
* Scale out or in based on time
749760
*/
@@ -1630,6 +1641,11 @@ export interface IAutoScalingGroup extends IResource, iam.IGrantable {
16301641
*/
16311642
addLifecycleHook(id: string, props: BasicLifecycleHookProps): LifecycleHook;
16321643

1644+
/**
1645+
* Add a pool of pre-initialized EC2 instances that sits alongside an Auto Scaling group
1646+
*/
1647+
addWarmPool(options?: WarmPoolOptions): WarmPool;
1648+
16331649
/**
16341650
* Scale out or in based on time
16351651
*/

packages/@aws-cdk/aws-autoscaling/lib/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from './step-scaling-policy';
99
export * from './target-tracking-scaling-policy';
1010
export * from './termination-policy';
1111
export * from './volume';
12+
export * from './warm-pool';
1213

1314
// AWS::AutoScaling CloudFormation Resources:
1415
export * from './autoscaling.generated';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { Lazy, Names, Resource } from '@aws-cdk/core';
2+
import { Construct } from 'constructs';
3+
import { IAutoScalingGroup } from './auto-scaling-group';
4+
import { CfnWarmPool } from './autoscaling.generated';
5+
6+
/**
7+
* Options for a warm pool
8+
*/
9+
export interface WarmPoolOptions {
10+
/**
11+
* Indicates whether instances in the Auto Scaling group can be returned to the warm pool on scale in.
12+
*
13+
* If the value is not specified, instances in the Auto Scaling group will be terminated
14+
* when the group scales in.
15+
*
16+
* @default false
17+
*/
18+
readonly reuseOnScaleIn?: boolean;
19+
20+
/**
21+
* The maximum number of instances that are allowed to be in the warm pool
22+
* or in any state except Terminated for the Auto Scaling group.
23+
*
24+
* If the value is not specified, Amazon EC2 Auto Scaling launches and maintains
25+
* the difference between the group's maximum capacity and its desired capacity.
26+
*
27+
* @default - max size of the Auto Scaling group
28+
*/
29+
readonly maxGroupPreparedCapacity?: number;
30+
/**
31+
* The minimum number of instances to maintain in the warm pool.
32+
*
33+
* @default 0
34+
*/
35+
readonly minSize?: number;
36+
/**
37+
* The instance state to transition to after the lifecycle actions are complete.
38+
*
39+
* @default PoolState.STOPPED
40+
*/
41+
readonly poolState?: PoolState;
42+
}
43+
44+
/**
45+
* Properties for a warm pool
46+
*/
47+
export interface WarmPoolProps extends WarmPoolOptions {
48+
/**
49+
* The Auto Scaling group to add the warm pool to.
50+
*/
51+
readonly autoScalingGroup: IAutoScalingGroup;
52+
}
53+
54+
/**
55+
* Define a warm pool
56+
*/
57+
export class WarmPool extends Resource {
58+
constructor(scope: Construct, id: string, props: WarmPoolProps) {
59+
super(scope, id, {
60+
physicalName: Lazy.string({ produce: () => Names.uniqueId(this) }),
61+
});
62+
63+
if (props.maxGroupPreparedCapacity && props.maxGroupPreparedCapacity < -1) {
64+
throw new Error('\'maxGroupPreparedCapacity\' parameter should be greater than or equal to -1');
65+
}
66+
67+
if (props.minSize && props.minSize < 0) {
68+
throw new Error('\'minSize\' parameter should be greater than or equal to 0');
69+
}
70+
71+
new CfnWarmPool(this, 'Resource', {
72+
autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName,
73+
instanceReusePolicy: props.reuseOnScaleIn !== undefined ? {
74+
reuseOnScaleIn: props.reuseOnScaleIn,
75+
} : undefined,
76+
maxGroupPreparedCapacity: props.maxGroupPreparedCapacity,
77+
minSize: props.minSize,
78+
poolState: props.poolState,
79+
});
80+
}
81+
}
82+
83+
/**
84+
* The instance state in the warm pool
85+
*/
86+
export enum PoolState {
87+
/**
88+
* Hibernated
89+
*
90+
* To use this state, prerequisites must be in place.
91+
* @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hibernating-prerequisites.html
92+
*/
93+
HIBERNATED = 'Hibernated',
94+
95+
/**
96+
* Running
97+
*/
98+
RUNNING = 'Running',
99+
100+
/**
101+
* Stopped
102+
*/
103+
STOPPED = 'Stopped',
104+
}

packages/@aws-cdk/aws-autoscaling/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"export:@aws-cdk/aws-autoscaling.IAutoScalingGroup",
124124
"props-physical-name:@aws-cdk/aws-autoscaling.AutoScalingGroupProps",
125125
"props-physical-name:@aws-cdk/aws-autoscaling.ScheduledActionProps",
126+
"props-physical-name:@aws-cdk/aws-autoscaling.WarmPoolProps",
126127
"props-default-doc:@aws-cdk/aws-autoscaling.EbsDeviceOptionsBase.iops",
127128
"docs-public-apis:@aws-cdk/aws-autoscaling.ScalingProcess.ADD_TO_LOAD_BALANCER",
128129
"docs-public-apis:@aws-cdk/aws-autoscaling.ScalingProcess.SCHEDULED_ACTIONS",

0 commit comments

Comments
 (0)