Skip to content

Commit

Permalink
Merge branch 'main' into houes/rfc-436-matchmaking-ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehouel authored Dec 5, 2022
2 parents 5ce2783 + 62c82d7 commit 0b52011
Show file tree
Hide file tree
Showing 208 changed files with 9,330 additions and 2,991 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:
### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)
* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
name: Stale issue job
steps:
- uses: aws-actions/stale-issue-cleanup@v6
- uses: aws-actions/stale-issue-cleanup@v5
with:
# Setting messages to an empty string will cause the automation to skip
# that category
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yarn-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
lerna exec --parallel ncu -- --upgrade --reject='@types/node,@types/prettier,@types/fs-extra,constructs,typescript,aws-sdk,aws-sdk-mock,${{ steps.list-packages.outputs.list }}' --target=minor
# Upgrade package.jsons in init templates
for pj in $(find packages/aws-cdk/lib/init-templates -name package.json); do
(cd $(dirname $pj) && ncu --upgrade --reject='@types/jest,@types/node,@types/prettier,@types/fs-extra,constructs,typescript,aws-sdk,aws-sdk-mock,ts-jest,jest,${{ steps.list-packages.outputs.list }}')
(cd $(dirname $pj) && ncu --upgrade --reject='@types/babel__traverse,@types/jest,@types/node,@types/prettier,@types/fs-extra,constructs,typescript,aws-sdk,aws-sdk-mock,ts-jest,jest,${{ steps.list-packages.outputs.list }}')
done
# Upgrade dependencies at an aws-eks integ test docker image
cd packages/@aws-cdk/aws-eks/test/sdk-call-integ-test-docker-app/app/ && ncu --upgrade --reject='@types/jest,@types/node,@types/prettier,@types/fs-extra,constructs,typescript,aws-sdk,aws-sdk-mock,ts-jest,jest,${{ steps.list-packages.outputs.list }}'
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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.

## [2.53.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.52.1-alpha.0...v2.53.0-alpha.0) (2022-11-29)

## [2.52.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.52.0-alpha.0...v2.52.1-alpha.0) (2022-11-28)


### Bug Fixes

* **appsync:** fully qualify service principal ([#23054](https://github.com/aws/aws-cdk/issues/23054)) ([d7141dd](https://github.com/aws/aws-cdk/commit/d7141dd7318fd6ee45206dfb35553e4a528decf9))

## [2.52.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.51.1-alpha.0...v2.52.0-alpha.0) (2022-11-27)

## [2.51.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.51.0-alpha.0...v2.51.1-alpha.0) (2022-11-18)
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

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.

## [2.53.0](https://github.com/aws/aws-cdk/compare/v2.52.1...v2.53.0) (2022-11-29)


### Features

* **lambda:** Add SnapStart resource spec patch ([4dda029](https://github.com/aws/aws-cdk/commit/4dda0295ac0ece271886609b140f71efebd3d22d))

## [2.52.1](https://github.com/aws/aws-cdk/compare/v2.52.0...v2.52.1) (2022-11-28)


### Bug Fixes

* **cli:** typescript init templates fails with error in build step ([#23125](https://github.com/aws/aws-cdk/issues/23125)) ([764b725](https://github.com/aws/aws-cdk/commit/764b725a31937abadeef97ba4306cea967afc61f)), closes [#23126](https://github.com/aws/aws-cdk/issues/23126)

## [2.52.0](https://github.com/aws/aws-cdk/compare/v2.51.1...v2.52.0) (2022-11-27)


Expand Down
51 changes: 36 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ $ yarn watch & # runs in the background

* Shout out to collaborators.

* Call out any new [unconventional dependencies](#adding-new-unconventional-dependencies) that are created as part of your PR.
* Call out any new [runtime dependencies](#adding-construct-runtime-dependencies) that are created as part of your PR.

* If not obvious (i.e. from unit tests), describe how you verified that your change works.

Expand Down Expand Up @@ -389,27 +389,48 @@ $ yarn watch & # runs in the background
* Make sure to update the PR title/description if things change. The PR title/description are going to be used as the
commit title/message and will appear in the CHANGELOG, so maintain them all the way throughout the process.

#### Adding construct runtime dependencies

Any tool that is not part of the CDK, and needs to be used by a construct during
deployment or runtime, can be included in the CDK Framework Library in one of two
ways.

1. Add a direct dependency on an npm package containing the tool. For example,
`@aws-cdk/asset-awscli-v1`.
2. Expose a property on the construct you are creating that allows users to
supply their own version of the tool. For example, the `eks.Cluster`
construct has a construct prop called `kubectlLayer` where you must provide a
version of `kubectl` from one of the `@aws-cdk/asset-kubectl-vXY` packages.
The version of `kubectl` must be compatible with the Kubernetes version of
the cluster.

Both options involve creating separate repositories (like this
[one](https://github.com/cdklabs/awscdk-asset-kubectl) for kubectl). If you
would like to introduce additional runtime dependencies, it likely involves
discussing with a CDK maintainer and opening a new repository in cdklabs that
vends the dependency as a lambda layer. Generally, each branch on the repository
will focus on a specific version of the dependency. For example, in
`awscdk-asset-kubectl`, branch `kubectl-v20/main` vends kubectl v1.20, branch
`kubectl-v21/main` vends kubectl v1.21, and so on.

**If your PR introduces runtime dependencies in lambda layers, make sure to call
it out in the description so that we can discuss the best way to manage that
dependency.**

#### Adding new unconventional dependencies

> :warning: Do not add these. If there is a tool that you want to use in your
CDK constructs, see [Adding construct runtime
dependencies](#Adding-construct-runtime-dependencies).

**For the aws-cdk an unconventional dependency is defined as any dependency that is not managed via the module's
`package.json` file.**

Sometimes constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
an auto upgrade process in place. The recommended way to update dependencies is through [dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates).
Sometimes, constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
an auto upgrade process in place. The recommended way to update dependencies is through
[dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates).
You can find the dependabot config file [here](./.github/dependabot.yml).

An example of this is the [@aws-cdk/lambda-layer-awscli](packages/@aws-cdk/lambda-layer-awscli) module.
This module creates a lambda layer that bundles the AWS CLI. This is considered an unconventional
dependency because the AWS CLI is bundled into the CDK as part of the build, and the version
of the AWS CLI that is bundled is not managed by the `package.json` file.

In order to automatically update the version of the AWS CLI, a custom build process was
created that takes upgrades into consideration. You can take a look at the files in
[packages/@aws-cdk/lambda-layer-awscli/layer](packages/@aws-cdk/lambda-layer-awscli/layer)
to see how the build works, but at a high level a [requirements.txt](packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt)
file was created to manage the version. This file was then added to [dependabot.yml](https://github.com/aws/aws-cdk/blob/ab57eb6d1ed69b40ed6ec774853c275785acace8/.github/dependabot.yml#L14-L20)
so that dependabot will automatically upgrade the version as new versions are released.

**If you think your PR introduces a new unconventional dependency, make sure to call it
out in the description so that we can discuss the best way to manage that dependency.**

Expand Down
4 changes: 2 additions & 2 deletions buildspec-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ phases:
# Install yarn if it wasn't already present in the image
- yarn --version || npm -g install yarn

# Packing the mono-libraries (monocdk & aws-cdk-lib) can cause
# memory errors. Increasing this value allows our build to more consistently succeed
# Packing aws-cdk-lib can cause memory errors. Increasing this value
# allows our build to more consistently succeed
- (command -v sysctl || yum install -y procps-ng) && /sbin/sysctl -w vm.max_map_count=2251954
pre_build:
commands:
Expand Down
4 changes: 2 additions & 2 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ phases:
# Install yarn if it wasn't already present in the image
- yarn --version || npm -g install yarn

# Packing the mono-libraries (monocdk & aws-cdk-lib) can cause
# memory errors. Increasing this value allows our build to more consistently succeed
# Packing aws-cdk-lib can cause memory errors. Increasing this value
# allows our build to more consistently succeed
- /sbin/sysctl -w vm.max_map_count=2251954
pre_build:
commands:
Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"packages/*",
"packages/@aws-cdk/*",
"packages/@aws-cdk-containers/*",
"packages/@monocdk-experiment/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/*",
"tools/@aws-cdk/*",
Expand Down
31 changes: 1 addition & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"packages/*",
"packages/@aws-cdk/*",
"packages/@aws-cdk-containers/*",
"packages/@monocdk-experiment/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/*",
"tools/@aws-cdk/*",
Expand Down Expand Up @@ -148,35 +147,7 @@
"aws-cdk-lib/table",
"aws-cdk-lib/table/**",
"aws-cdk-lib/yaml",
"aws-cdk-lib/yaml/**",
"monocdk/@balena/dockerignore",
"monocdk/@balena/dockerignore/**",
"monocdk/case",
"monocdk/case/**",
"monocdk/chalk",
"monocdk/chalk/**",
"monocdk/diff",
"monocdk/diff/**",
"monocdk/fast-deep-equal",
"monocdk/fast-deep-equal/**",
"monocdk/fs-extra",
"monocdk/fs-extra/**",
"monocdk/ignore",
"monocdk/ignore/**",
"monocdk/jsonschema",
"monocdk/jsonschema/**",
"monocdk/minimatch",
"monocdk/minimatch/**",
"monocdk/punycode",
"monocdk/punycode/**",
"monocdk/semver",
"monocdk/semver/**",
"monocdk/string-width",
"monocdk/string-width/**",
"monocdk/table",
"monocdk/table/**",
"monocdk/yaml",
"monocdk/yaml/**"
"aws-cdk-lib/yaml/**"
]
},
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ describe('AppSync API Key Authorization', () => {
});

test('apiKeyConfig creates default with valid expiration date', () => {
const expirationDate: number = cdk.Expiration.after(cdk.Duration.days(10)).toEpoch();
const expires = cdk.Expiration.after(cdk.Duration.days(10));
const expirationDate: number = expires.toEpoch();

// WHEN
new appsync.GraphqlApi(stack, 'API', {
Expand All @@ -100,7 +101,7 @@ describe('AppSync API Key Authorization', () => {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.API_KEY,
apiKeyConfig: {
expires: cdk.Expiration.after(cdk.Duration.days(10)),
expires,
},
},
},
Expand Down
7 changes: 7 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 @@ -408,6 +408,13 @@ export enum SpotAllocationStrategy {
* honors the instance type priorities on a best-effort basis but optimizes for capacity first.
*/
CAPACITY_OPTIMIZED_PRIORITIZED = 'capacity-optimized-prioritized',

/**
* The price and capacity optimized allocation strategy looks at both price and
* capacity to select the Spot Instance pools that are the least likely to be
* interrupted and have the lowest possible price.
*/
PRICE_CAPACITY_OPTIMIZED = 'price-capacity-optimized',
}

/**
Expand Down
41 changes: 41 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,47 @@ test('can use Vpc imported from unparseable list tokens', () => {
});
});

test('add price-capacity-optimized', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const lt = LaunchTemplate.fromLaunchTemplateAttributes(stack, 'imported-lt', {
launchTemplateId: 'test-lt-id',
versionNumber: '0',
});

new autoscaling.AutoScalingGroup(stack, 'mip-asg', {
mixedInstancesPolicy: {
launchTemplate: lt,
launchTemplateOverrides: [{
instanceType: new InstanceType('t4g.micro'),
launchTemplate: lt,
weightedCapacity: 9,
}],
instancesDistribution: {
onDemandAllocationStrategy: OnDemandAllocationStrategy.PRIORITIZED,
onDemandBaseCapacity: 1,
onDemandPercentageAboveBaseCapacity: 2,
spotAllocationStrategy: SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED,
spotInstancePools: 3,
spotMaxPrice: '4',
},
},
vpc: mockVpc(stack),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::AutoScaling::AutoScalingGroup', {
MixedInstancesPolicy: {
InstancesDistribution: {
SpotAllocationStrategy: 'price-capacity-optimized',
},
},
});
});


function mockSecurityGroup(stack: cdk.Stack) {
return ec2.SecurityGroup.fromSecurityGroupId(stack, 'MySG', 'most-secure');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { Statistic } from '@aws-cdk/aws-cloudwatch';
import { Stats } from '@aws-cdk/aws-cloudwatch';
import { Duration, Resource } from '@aws-cdk/core';
import { ICertificate } from './certificate';

Expand All @@ -26,7 +26,7 @@ export abstract class CertificateBase extends Resource implements ICertificate {
metricName: 'DaysToExpiry',
namespace: 'AWS/CertificateManager',
region: this.region,
statistic: Statistic.MINIMUM,
statistic: Stats.MINIMUM,
});
}
}
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,18 @@ const distribution = cloudfront.Distribution.fromDistributionAttributes(this, 'I
});
```

### Permissions

Use the `grant()` method to allow actions on the distribution.
`grantCreateInvalidation()` is a shorthand to allow `CreateInvalidation`.

```ts
declare const distribution: cloudfront.Distribution;
declare const lambdaFn: lambda.Function;
distribution.grant(lambdaFn, 'cloudfront:ListInvalidations', 'cloudfront:GetInvalidation');
distribution.grantCreateInvalidation(lambdaFn);
```

## Migrating from the original CloudFrontWebDistribution to the newer Distribution construct

It's possible to migrate a distribution from the original to the modern API.
Expand Down
Loading

0 comments on commit 0b52011

Please sign in to comment.