Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 31, 2021
2 parents 2df38a2 + e2cb83b commit 1e88f36
Show file tree
Hide file tree
Showing 232 changed files with 36,209 additions and 36,159 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ updates:
schedule:
interval: "weekly"
labels:
- "pr/auto-approve"
- "auto-approve"
open-pull-requests-limit: 5
2 changes: 1 addition & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ These workflows and actions are configured in the AWS CDK GitHub repository.

### Auto Approve
[auto-approve.yml](auto-approve.yml): Approves merging PRs with the
`pr/auto-approve` label.
`auto-approve` label.
Owner: Core CDK team

### PR Linter
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Approve PRs with "pr/auto-approve". mergify takes care of the actual merge.
# Approve PRs with "auto-approve". mergify takes care of the actual merge.

name: auto-approve
on:
Expand All @@ -7,7 +7,7 @@ on:

jobs:
auto-approve:
if: contains(github.event.pull_request.labels.*.name, 'pr/auto-approve')
if: contains(github.event.pull_request.labels.*.name, 'auto-approve')
runs-on: ubuntu-latest
permissions:
pull-requests: write
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/issue-label-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ jobs:
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
excluded-expressions: "[CDK CLI Version|TypeScript|Java|Python]"
area-is-keyword: true
parameters: >
[
{"area":"package/tools","keywords":["cli","command line","init","synth","diff","bootstrap"],"labels":["package/tools"],"assignees":["rix0rrr"]},
{"area":"@aws-cdk/alexa-ask","keywords":["alexa-ask","alexa", "cfnskill"],"labels":["@aws-cdk/alexa-ask"],"assignees":["madeline-k"]},
{"area":"@aws-cdk/app-delivery","keywords":["app-delivery","PipelineDeployStackAction"],"labels":["@aws-cdk/app-delivery"],"assignees":["skinny85"]},
{"area":"@aws-cdk/assert","keywords":["assert", "@aws-cdk/assert"],"labels":["@aws-cdk/assert"],"assignees":["kaizen3031593"]},
{"area":"@aws-cdk/assertions","keywords":["assertions", "@aws-cdk/assertions"],"labels":["@aws-cdk/assertions"],"assignees":["kaizen3031593"]},
{"area":"@aws-cdk/assert","keywords":["assert"],"labels":["@aws-cdk/assert"],"assignees":["kaizen3031593"]},
{"area":"@aws-cdk/assertions","keywords":["assertions"],"labels":["@aws-cdk/assertions"],"assignees":["kaizen3031593"]},
{"area":"@aws-cdk/assets","keywords":["assets","staging"],"labels":["@aws-cdk/assets"],"assignees":["eladb"]},
{"area":"@aws-cdk/aws-accessanalyzer","keywords":["aws-accessanalyzer","accessanalyzer","cfnanalyzer"],"labels":["@aws-cdk/aws-accessanalyzer"],"assignees":["skinny85"]},
{"area":"@aws-cdk/aws-acmpca","keywords":["aws-acmpca","acmpca","certificateauthority"],"labels":["@aws-cdk/aws-acmpca"],"assignees":["skinny85"]},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
pull-requests: write
issues: write
steps:
- run: gh pr edit ${{ github.event.pull_request.number }} --add-label "pr/auto-approve" -R ${{ github.repository }}
- run: gh pr edit ${{ github.event.pull_request.number }} --add-label "auto-approve" -R ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/yarn-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
title: 'chore: npm-check-updates && yarn upgrade'
body: |-
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
labels: contribution/core,dependencies,pr/auto-approve
labels: contribution/core,dependencies,auto-approve
team-reviewers: aws-cdk-team
# Github prevents further Github actions to be run if the default Github token is used.
# Instead use a privileged token here, so further GH actions can be triggered on this PR.
Expand Down
1 change: 0 additions & 1 deletion pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ scripts/run-rosetta.sh --infuse --pkgs-from $TMPDIR/jsii.txt
echo "Packaging jsii modules" >&2
$PACMAK \
--verbose \
--rosetta-tablet samples.tabl.json \
$(cat $TMPDIR/jsii.txt)

# Non-jsii packaging, which means running 'package' in every individual
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
},
"devDependencies": {
"@yarnpkg/lockfile": "^1.1.0",
"conventional-changelog-cli": "^2.1.1",
"cdk-generate-synthetic-examples": "^0.1.1",
"conventional-changelog-cli": "^2.2.2",
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.8",
"jest-junit": "^13.0.0",
"jsii-diff": "^1.47.0",
"jsii-pacmak": "^1.47.0",
"jsii-reflect": "^1.47.0",
"jsii-rosetta": "^1.47.0",
"jsii-diff": "^1.50.0",
"jsii-pacmak": "^1.50.0",
"jsii-reflect": "^1.50.0",
"jsii-rosetta": "^1.50.0",
"lerna": "^4.0.0",
"patch-package": "^6.4.7",
"standard-version": "^9.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@aws-cdk/cdk-integ-tools": "0.0.0",
"@aws-cdk/aws-autoscaling": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"jest": "^27.4.3",
"jest": "^27.4.5",
"@aws-cdk/pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"fast-check": "^2.20.0",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assert-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"jest": "^27.4.3",
"ts-jest": "^27.1.1"
"jest": "^27.4.5",
"ts-jest": "^27.1.2"
},
"dependencies": {
"@aws-cdk/cloud-assembly-schema": "0.0.0",
Expand All @@ -40,7 +40,7 @@
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.3.69",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"repository": {
"url": "https:/aws/aws-cdk.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"aws-cdk-migration": "0.0.0",
"constructs": "^3.3.69",
"jest": "^27.3.1",
"ts-jest": "^27.1.1"
"ts-jest": "^27.1.2"
},
"dependencies": {
"@aws-cdk/cloudformation-diff": "0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assertions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.0.3",
"constructs": "^3.3.69",
"jest": "^27.4.3",
"ts-jest": "^27.1.1"
"jest": "^27.4.5",
"ts-jest": "^27.1.2"
},
"dependencies": {
"@aws-cdk/cloud-assembly-schema": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@types/jest": "^27.0.3",
"@types/sinon": "^9.0.11",
"aws-cdk": "0.0.0",
"jest": "^27.4.3",
"jest": "^27.4.5",
"sinon": "^9.2.4",
"ts-mock-imports": "^1.3.8"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplifyuibuilder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^26.0.22"
"@types/jest": "^26.0.24"
},
"dependencies": {
"@aws-cdk/core": "0.0.0"
Expand Down
22 changes: 21 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Duration, IResource, Resource, Stack, Token } from '@aws-cdk/core';
import { ArnFormat, Duration, IResource, Resource, Stack, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { AccessLogFormat, IAccessLogDestination } from './access-log';
import { CfnStage } from './apigateway.generated';
Expand Down Expand Up @@ -273,6 +273,26 @@ export class Stage extends Resource implements IStage {
return `https://${this.restApi.restApiId}.execute-api.${Stack.of(this).region}.${Stack.of(this).urlSuffix}/${this.stageName}${path}`;
}

/**
* Returns the resource ARN for this stage:
*
* arn:aws:apigateway:{region}::/restapis/{restApiId}/stages/{stageName}
*
* Note that this is separate from the execute-api ARN for methods and resources
* within this stage.
*
* @attribute
*/
public get stageArn() {
return Stack.of(this).formatArn({
arnFormat: ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME,
service: 'apigateway',
account: '',
resource: 'restapis',
resourceName: `${this.restApi.restApiId}/stages/${this.stageName}`,
});
}

private renderMethodSettings(props: StageProps): CfnStage.MethodSettingProperty[] | undefined {
const settings = new Array<CfnStage.MethodSettingProperty>();
const self = this;
Expand Down
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/stage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,38 @@ describe('stage', () => {
});
});

test('"stageResourceArn" returns the ARN for the stage', () => {
// GIVEN
const stack = new cdk.Stack();
const api = new apigateway.RestApi(stack, 'test-api');
const deployment = new apigateway.Deployment(stack, 'test-deploymnet', {
api,
});
api.root.addMethod('GET');

// WHEN
const stage = new apigateway.Stage(stack, 'test-stage', {
deployment,
});

// THEN
expect(stack.resolve(stage.stageArn)).toEqual({
'Fn::Join': [
'',
[
'arn:',
{ Ref: 'AWS::Partition' },
':apigateway:',
{ Ref: 'AWS::Region' },
'::/restapis/',
{ Ref: 'testapiD6451F70' },
'/stages/',
{ Ref: 'teststage8788861E' },
],
],
});
});

test('custom method settings can be set by their path', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/cdk-integ-tools": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/aws-lambda": "^8.10.86",
"@types/aws-lambda": "^8.10.89",
"@types/jest": "^27.0.3"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"fast-check": "^2.20.0",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/aws-autoscaling-common": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appmesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/aws-acmpca": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/aws-cognito": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/core": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-autoscaling-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"fast-check": "^2.20.0",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/aws-iam": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-autoscaling-hooktargets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.0.3",
"jest": "^27.4.3"
"jest": "^27.4.5"
},
"dependencies": {
"@aws-cdk/aws-autoscaling": "0.0.0",
Expand Down
26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,32 @@ new autoscaling.AutoScalingGroup(this, 'ASG', {
});
```

## Termination policies

Auto Scaling uses [termination policies](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html)
to determine which instances it terminates first during scale-in events. You
can specify one or more termination policies with the `terminationPolicies`
property:

```ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
declare const machineImage: ec2.IMachineImage;

new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType,
machineImage,

// ...

terminationPolicies: [
autoscaling.TerminationPolicy.OLDEST_INSTANCE,
autoscaling.TerminationPolicy.DEFAULT,
],
});
```

## Protecting new instances from being terminated on scale-in

By default, Auto Scaling can terminate an instance at any time after launch when
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BasicLifecycleHookProps, LifecycleHook } from './lifecycle-hook';
import { BasicScheduledActionProps, ScheduledAction } from './scheduled-action';
import { BasicStepScalingPolicyProps, StepScalingPolicy } from './step-scaling-policy';
import { BaseTargetTrackingProps, PredefinedMetric, TargetTrackingScalingPolicy } from './target-tracking-scaling-policy';
import { TerminationPolicy } from './termination-policy';
import { BlockDevice, BlockDeviceVolume, EbsDeviceVolumeType } from './volume';

/**
Expand Down Expand Up @@ -314,6 +315,16 @@ export interface CommonAutoScalingGroupProps {
* @default - Auto generated by CloudFormation
*/
readonly autoScalingGroupName?: string;

/**
* A policy or a list of policies that are used to select the instances to
* terminate. The policies are executed in the order that you list them.
*
* @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html
*
* @default - `TerminationPolicy.DEFAULT`
*/
readonly terminationPolicies?: TerminationPolicy[];
}

/**
Expand Down Expand Up @@ -1052,6 +1063,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
healthCheckGracePeriod: props.healthCheck && props.healthCheck.gracePeriod && props.healthCheck.gracePeriod.toSeconds(),
maxInstanceLifetime: this.maxInstanceLifetime ? this.maxInstanceLifetime.toSeconds() : undefined,
newInstancesProtectedFromScaleIn: Lazy.any({ produce: () => this.newInstancesProtectedFromScaleIn }),
terminationPolicies: props.terminationPolicies,
};

if (!hasPublic && props.associatePublicIpAddress) {
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export * from './scheduled-action';
export * from './step-scaling-action';
export * from './step-scaling-policy';
export * from './target-tracking-scaling-policy';
export * from './termination-policy';
export * from './volume';

// AWS::AutoScaling CloudFormation Resources:
export * from './autoscaling.generated';
export * from './autoscaling.generated';
Loading

0 comments on commit 1e88f36

Please sign in to comment.