Skip to content

Commit 5a0595e

Browse files
authored
2 parents af1fb7c + 8f61282 commit 5a0595e

File tree

909 files changed

+34909
-4753
lines changed

Some content is hidden

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

909 files changed

+34909
-4753
lines changed

CHANGELOG.v2.alpha.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
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+
## [2.46.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.45.0-alpha.0...v2.46.0-alpha.0) (2022-10-13)
6+
7+
8+
### Features
9+
10+
* **integ-tests:** add ability to `wait` for assertions to pass ([#22335](https://github.com/aws/aws-cdk/issues/22335)) ([700f9c4](https://github.com/aws/aws-cdk/commit/700f9c4d465684b784f50ec74e897c9031a639c5))
11+
* **integ-tests:** allow for user provided assertions stack ([#22404](https://github.com/aws/aws-cdk/issues/22404)) ([39089f5](https://github.com/aws/aws-cdk/commit/39089f5eabc61c2a546391742ff2cf906f8e0f8b))
12+
* **synthetics:** new runtime synthetics nodejs puppeteer 3 6 ([#22374](https://github.com/aws/aws-cdk/issues/22374)) ([e0c0b56](https://github.com/aws/aws-cdk/commit/e0c0b56dded26a897dc6243298947bd4e69321b2))
13+
14+
15+
### Bug Fixes
16+
17+
* **appsync:** can not use Tokens in the name of a DataSource ([#22378](https://github.com/aws/aws-cdk/issues/22378)) ([511eb79](https://github.com/aws/aws-cdk/commit/511eb79cba734bcd9e013d5dfbf262c75a522f09)), closes [#18900](https://github.com/aws/aws-cdk/issues/18900)
18+
* **aws-lambda-python:** export poetry dependencies without hashes ([#22351](https://github.com/aws/aws-cdk/issues/22351)) ([76482f6](https://github.com/aws/aws-cdk/commit/76482f6847a46806c1a309d2f9335a3d6e838fc6)), closes [#14201](https://github.com/aws/aws-cdk/issues/14201) [#19232](https://github.com/aws/aws-cdk/issues/19232)
19+
* **lambda-python:** commands run non-sequentially on Graviton when building container image ([#22398](https://github.com/aws/aws-cdk/issues/22398)) ([e427fd6](https://github.com/aws/aws-cdk/commit/e427fd6f4a186784e345b8f88424d74c004f1e5a)), closes [#22012](https://github.com/aws/aws-cdk/issues/22012)
20+
521
## [2.45.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.44.0-alpha.0...v2.45.0-alpha.0) (2022-10-06)
622

723

CHANGELOG.v2.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
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+
## [2.46.0](https://github.com/aws/aws-cdk/compare/v2.45.0...v2.46.0) (2022-10-13)
6+
7+
8+
### Features
9+
10+
* **aws-certificatemanager:** Add ability to specify the certificate name ([#22301](https://github.com/aws/aws-cdk/issues/22301)) ([614ba92](https://github.com/aws/aws-cdk/commit/614ba92ba77e29c10ea4642a64e5b50b5dc775b8))
11+
* **aws-ec2:** add metadata options support for launchTemplate construct ([#22312](https://github.com/aws/aws-cdk/issues/22312)) ([9297bd0](https://github.com/aws/aws-cdk/commit/9297bd04884ebd05888fd14121256329dac82b43))
12+
* **cfnspec:** cloudformation spec v92.0.0 ([#22435](https://github.com/aws/aws-cdk/issues/22435)) ([064a1a6](https://github.com/aws/aws-cdk/commit/064a1a650c6f26d6a3087a8d39971ba33413d8ce))
13+
* **cloudfront-origins:** allow setting a user defined origin id ([#22349](https://github.com/aws/aws-cdk/issues/22349)) ([239215f](https://github.com/aws/aws-cdk/commit/239215fb8ceb4df5cd67669ad5daca39fb65543f)), closes [#2756](https://github.com/aws/aws-cdk/issues/2756)
14+
* **ec2:** adds persist option to user data on windows instances ([#21709](https://github.com/aws/aws-cdk/issues/21709)) ([cb1506f](https://github.com/aws/aws-cdk/commit/cb1506f090e36a6da78b8a8a1edf9a1256478311))
15+
* **sns:** topic name with `.fifo` suffix generated automatically ([#22375](https://github.com/aws/aws-cdk/issues/22375)) ([ba201cf](https://github.com/aws/aws-cdk/commit/ba201cf1d9768f9ac5d3328ec425bf566f088a16)), closes [#18740](https://github.com/aws/aws-cdk/issues/18740)
16+
* **sqs:** add enforceSSL property to enforce encryption of data in transit ([#22363](https://github.com/aws/aws-cdk/issues/22363)) ([f1886cf](https://github.com/aws/aws-cdk/commit/f1886cf82c50abc4e419f1450abfc3df0c5b0324))
17+
18+
19+
### Bug Fixes
20+
21+
* **apigateway:** cannot create an ApiKey with an imported RestApi ([#22368](https://github.com/aws/aws-cdk/issues/22368)) ([83c4123](https://github.com/aws/aws-cdk/commit/83c4123273fda2a2e349b55f1e50d5afa1c7dd9d)), closes [#22102](https://github.com/aws/aws-cdk/issues/22102)
22+
* **apigateway:** CORS OPTIONS method should not require auth ([#22402](https://github.com/aws/aws-cdk/issues/22402)) ([ef72089](https://github.com/aws/aws-cdk/commit/ef72089d7cdf5dbaa1f172eecd29ee525f650b32)), closes [#8615](https://github.com/aws/aws-cdk/issues/8615)
23+
* **core:** asset bundling skipped when using --exclusively with custom stack name ([#21248](https://github.com/aws/aws-cdk/issues/21248)) ([209ddea](https://github.com/aws/aws-cdk/commit/209ddea44744509d74a080fdbd31cbb978fc8a96)), closes [/github.com/aws/aws-cdk/issues/19927#issuecomment-1189916912](https://github.com/aws//github.com/aws/aws-cdk/issues/19927/issues/issuecomment-1189916912)
24+
* some custom resources don't work in opt-in regions ([#22370](https://github.com/aws/aws-cdk/issues/22370)) ([456a2c7](https://github.com/aws/aws-cdk/commit/456a2c75881fe8df3803db3787b48f8d9f97f09e)), closes [#22022](https://github.com/aws/aws-cdk/issues/22022)
25+
* **cli:** state machine hotswap fails if the `DependsOn` change ([#22396](https://github.com/aws/aws-cdk/issues/22396)) ([0d44db2](https://github.com/aws/aws-cdk/commit/0d44db2c211204b85002342ce758aca0552e851c))
26+
* **core:** Custom Resource type length validation ([#22118](https://github.com/aws/aws-cdk/issues/22118)) ([c186e2d](https://github.com/aws/aws-cdk/commit/c186e2ddcffb25647b971ba1b90faa850552d219))
27+
* **custom-resources:** provider can fail if S3 has brown-outs ([#22362](https://github.com/aws/aws-cdk/issues/22362)) ([cdedf60](https://github.com/aws/aws-cdk/commit/cdedf606277f50a2f7e20b09560f6e14b11bbc19))
28+
* **ec2:** cannot deploy SecurityGroup with allowAllIpv6Outbound ([#22414](https://github.com/aws/aws-cdk/issues/22414)) ([bb16d97](https://github.com/aws/aws-cdk/commit/bb16d9729daea2702b32df81fc8259b0afd652fa)), closes [#22407](https://github.com/aws/aws-cdk/issues/22407)
29+
* **ecs:** removed explicit addition of ecs deployment type when circuit breaker is enabled ([#22328](https://github.com/aws/aws-cdk/issues/22328)) ([635129c](https://github.com/aws/aws-cdk/commit/635129ca95313afef7b3d8fc62d077afbfd0c088)), closes [#16126](https://github.com/aws/aws-cdk/issues/16126) [#16919](https://github.com/aws/aws-cdk/issues/16919)
30+
* half-written asset zips can be uploaded if process is interrupted ([#22393](https://github.com/aws/aws-cdk/issues/22393)) ([2ed006e](https://github.com/aws/aws-cdk/commit/2ed006e50b15dfca96395d442ccee648abdbb374)), closes [#18459](https://github.com/aws/aws-cdk/issues/18459)
31+
32+
33+
### Reverts
34+
35+
* "fix(ecs): removed explicit addition of ecs deployment type when circuit breaker is enabled ([#22328](https://github.com/aws/aws-cdk/issues/22328))" ([#22418](https://github.com/aws/aws-cdk/issues/22418)) ([0f002e2](https://github.com/aws/aws-cdk/commit/0f002e2009bbab2e10c08cdf908c5091ba61b754)), closes [/github.com/aws/aws-cdk/issues/16126#issuecomment-1271626957](https://github.com/aws//github.com/aws/aws-cdk/issues/16126/issues/issuecomment-1271626957)
36+
537
## [2.45.0](https://github.com/aws/aws-cdk/compare/v2.44.0...v2.45.0) (2022-10-06)
638

739

docs/DESIGN_GUIDELINES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ new lambda.Function(this, 'MyFunction', {
671671
code: lambda.Code.bucket(myBucket, 'bundle.zip'), // or
672672
code: lambda.Code.inline('code')
673673
// etc
674-
}
674+
})
675675
```
676676

677677
### Attributes

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"devDependencies": {
1919
"@types/prettier": "2.6.0",
2020
"@yarnpkg/lockfile": "^1.1.0",
21-
"cdk-generate-synthetic-examples": "^0.1.17",
21+
"cdk-generate-synthetic-examples": "^0.1.29",
2222
"conventional-changelog-cli": "^2.2.2",
2323
"fs-extra": "^9.1.0",
2424
"graceful-fs": "^4.2.10",
2525
"jest-junit": "^13.2.0",
26-
"jsii-diff": "^1.68.0",
27-
"jsii-pacmak": "^1.68.0",
28-
"jsii-reflect": "^1.68.0",
29-
"jsii-rosetta": "^1.68.0",
26+
"jsii-diff": "^1.69.0",
27+
"jsii-pacmak": "^1.69.0",
28+
"jsii-reflect": "^1.69.0",
29+
"jsii-rosetta": "^1.69.0",
3030
"lerna": "^4.0.0",
3131
"patch-package": "^6.4.7",
3232
"semver": "^6.3.0",

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,22 @@ declare const lambdaFn: lambda.Function;
389389
importedKey.grantRead(lambdaFn);
390390
```
391391

392+
### Adding an API Key to an imported RestApi
393+
394+
API Keys are added to ApiGateway Stages, not to the API itself. When you import a RestApi
395+
it does not have any information on the Stages that may be associated with it. Since adding an API
396+
Key requires a stage, you should instead add the Api Key to the imported Stage.
397+
398+
```ts
399+
declare const restApi: apigateway.IRestApi;
400+
const importedStage = apigateway.Stage.fromStageAttributes(this, 'imported-stage', {
401+
stageName: 'myStageName',
402+
restApi,
403+
});
404+
405+
importedStage.addApiKey('MyApiKey');
406+
```
407+
392408
### ⚠️ Multiple API Keys
393409

394410
It is possible to specify multiple API keys for a given Usage Plan, by calling `usagePlan.addApiKey()`.
@@ -426,7 +442,7 @@ declare const api: apigateway.RestApi;
426442

427443
const key = new apigateway.RateLimitedApiKey(this, 'rate-limited-api-key', {
428444
customerId: 'hello-customer',
429-
resources: [api],
445+
stages: [api.deploymentStage],
430446
quota: {
431447
limit: 10000,
432448
period: apigateway.Period.MONTH
@@ -724,7 +740,51 @@ books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
724740

725741
A full working example is shown below.
726742

727-
[Full token authorizer example](test/authorizers/integ.token-authorizer.lit.ts).
743+
```ts
744+
import * as path from 'path';
745+
import * as lambda from '@aws-cdk/aws-lambda';
746+
import { App, Stack } from '@aws-cdk/core';
747+
import { MockIntegration, PassthroughBehavior, RestApi, TokenAuthorizer, Cors } from '../../lib';
748+
749+
/// !show
750+
const app = new App();
751+
const stack = new Stack(app, 'TokenAuthorizerInteg');
752+
753+
const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
754+
runtime: lambda.Runtime.NODEJS_14_X,
755+
handler: 'index.handler',
756+
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
757+
});
758+
759+
const authorizer = new TokenAuthorizer(stack, 'MyAuthorizer', {
760+
handler: authorizerFn,
761+
});
762+
763+
const restapi = new RestApi(stack, 'MyRestApi', {
764+
cloudWatchRole: true,
765+
defaultMethodOptions: {
766+
authorizer,
767+
},
768+
defaultCorsPreflightOptions: {
769+
allowOrigins: Cors.ALL_ORIGINS,
770+
},
771+
});
772+
773+
774+
restapi.root.addMethod('ANY', new MockIntegration({
775+
integrationResponses: [
776+
{ statusCode: '200' },
777+
],
778+
passthroughBehavior: PassthroughBehavior.NEVER,
779+
requestTemplates: {
780+
'application/json': '{ "statusCode": 200 }',
781+
},
782+
}), {
783+
methodResponses: [
784+
{ statusCode: '200' },
785+
],
786+
});
787+
```
728788

729789
By default, the `TokenAuthorizer` looks for the authorization token in the request header with the key 'Authorization'. This can,
730790
however, be modified by changing the `identitySource` property.

packages/@aws-cdk/aws-apigateway/lib/api-key.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Construct } from 'constructs';
44
import { CfnApiKey } from './apigateway.generated';
55
import { ResourceOptions } from './resource';
66
import { IRestApi } from './restapi';
7+
import { IStage } from './stage';
78
import { QuotaSettings, ThrottleSettings, UsagePlan, UsagePlanPerApiStage } from './usage-plan';
89

910
/**
@@ -56,9 +57,17 @@ export interface ApiKeyProps extends ApiKeyOptions {
5657
/**
5758
* A list of resources this api key is associated with.
5859
* @default none
60+
* @deprecated - use `stages` instead
5961
*/
6062
readonly resources?: IRestApi[];
6163

64+
/**
65+
* A list of Stages this api key is associated with.
66+
*
67+
* @default - the api key is not associated with any stages
68+
*/
69+
readonly stages?: IStage[];
70+
6271
/**
6372
* An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.
6473
* @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-customerid
@@ -168,7 +177,7 @@ export class ApiKey extends ApiKeyBase {
168177
enabled: props.enabled ?? true,
169178
generateDistinctId: props.generateDistinctId,
170179
name: this.physicalName,
171-
stageKeys: this.renderStageKeys(props.resources),
180+
stageKeys: this.renderStageKeys(props.resources, props.stages),
172181
value: props.value,
173182
});
174183

@@ -182,17 +191,29 @@ export class ApiKey extends ApiKeyBase {
182191
});
183192
}
184193

185-
private renderStageKeys(resources: IRestApi[] | undefined): CfnApiKey.StageKeyProperty[] | undefined {
186-
if (!resources) {
194+
private renderStageKeys(resources?: IRestApi[], stages?: IStage[]): CfnApiKey.StageKeyProperty[] | undefined {
195+
if (!resources && !stages) {
187196
return undefined;
188197
}
189198

190-
return resources.map((resource: IRestApi) => {
191-
const restApi = resource;
192-
const restApiId = restApi.restApiId;
193-
const stageName = restApi.deploymentStage!.stageName.toString();
194-
return { restApiId, stageName };
195-
});
199+
if (resources && stages) {
200+
throw new Error('Only one of "resources" or "stages" should be provided');
201+
}
202+
203+
return resources
204+
? resources.map((resource: IRestApi) => {
205+
const restApi = resource;
206+
if (!restApi.deploymentStage) {
207+
throw new Error('Cannot add an ApiKey to a RestApi that does not contain a "deploymentStage".\n'+
208+
'Either set the RestApi.deploymentStage or create an ApiKey from a Stage');
209+
}
210+
const restApiId = restApi.restApiId;
211+
const stageName = restApi.deploymentStage!.stageName.toString();
212+
return { restApiId, stageName };
213+
})
214+
: stages ? stages.map((stage => {
215+
return { restApiId: stage.restApi.restApiId, stageName: stage.stageName };
216+
})) : undefined;
196217
}
197218
}
198219

@@ -258,4 +279,4 @@ const writePermissions = [
258279
'apigateway:PUT',
259280
'apigateway:PATCH',
260281
'apigateway:DELETE',
261-
];
282+
];

packages/@aws-cdk/aws-apigateway/lib/domain-name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface DomainNameOptions {
3939
/**
4040
* The Transport Layer Security (TLS) version + cipher suite for this domain name.
4141
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html
42-
* @default SecurityPolicy.TLS_1_0
42+
* @default SecurityPolicy.TLS_1_2
4343
*/
4444
readonly securityPolicy?: SecurityPolicy;
4545

packages/@aws-cdk/aws-apigateway/lib/method.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class Method extends Resource {
186186

187187
const defaultMethodOptions = props.resource.defaultMethodOptions || {};
188188
const authorizer = options.authorizer || defaultMethodOptions.authorizer;
189-
const authorizerId = authorizer?.authorizerId;
189+
const authorizerId = authorizer?.authorizerId ? authorizer.authorizerId : undefined;
190190

191191
const authorizationTypeOption = options.authorizationType || defaultMethodOptions.authorizationType;
192192
const authorizationType = authorizer?.authorizationType || authorizationTypeOption || AuthorizationType.NONE;

packages/@aws-cdk/aws-apigateway/lib/resource.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CfnResource, CfnResourceProps } from './apigateway.generated';
44
import { Cors, CorsOptions } from './cors';
55
import { Integration } from './integration';
66
import { MockIntegration } from './integrations';
7-
import { Method, MethodOptions } from './method';
7+
import { Method, MethodOptions, AuthorizationType } from './method';
88
import { IRestApi, RestApi } from './restapi';
99

1010
export interface IResource extends IResourceBase {
@@ -296,6 +296,12 @@ export abstract class ResourceBase extends ResourceConstruct implements IResourc
296296
{ statusCode: `${statusCode}`, responseParameters: integrationResponseParams, responseTemplates: renderResponseTemplate() },
297297
],
298298
}), {
299+
authorizer: {
300+
authorizerId: '',
301+
authorizationType: AuthorizationType.NONE,
302+
},
303+
apiKeyRequired: false,
304+
authorizationType: AuthorizationType.NONE,
299305
methodResponses: [
300306
{ statusCode: `${statusCode}`, responseParameters: methodResponseParams },
301307
],

packages/@aws-cdk/aws-apigateway/lib/restapi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ export abstract class RestApiBase extends Resource implements IRestApi {
403403
}
404404

405405
/**
406-
* Add an ApiKey
406+
* Add an ApiKey to the deploymentStage
407407
*/
408408
public addApiKey(id: string, options?: ApiKeyOptions): IApiKey {
409409
return new ApiKey(this, id, {
410-
resources: [this],
410+
stages: [this.deploymentStage],
411411
...options,
412412
});
413413
}

0 commit comments

Comments
 (0)