Skip to content

Commit d165bba

Browse files
authored
Merge branch 'master' into ismaelmartinez/add-endpointconfiguration-for-openapi3
2 parents d224d73 + e3f6ae3 commit d165bba

File tree

79 files changed

+1255
-417
lines changed

Some content is hidden

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

79 files changed

+1255
-417
lines changed

.github/ISSUE_TEMPLATE/bug.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ description of the bug:
1818
minimal amount of code that causes the bug (if possible) or a reference:
1919
-->
2020

21-
22-
23-
24-
### Error Log
21+
### What did you expect to happen?
2522

2623
<!--
27-
what is the error message you are seeing?
24+
What were you trying to achieve by performing the steps above?
2825
-->
2926

27+
### What actually happened?
3028

29+
<!--
30+
What is the unexpected behavior you were seeing? If you got an error, paste it here.
31+
-->
3132

3233

3334
### Environment

.github/workflows/issue-label-assign.yml

+45-44
Large diffs are not rendered by default.

packages/@aws-cdk/assert/lib/synth-utils.ts

+23-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import * as core from '@aws-cdk/core';
44
import * as cxapi from '@aws-cdk/cx-api';
55

66
export class SynthUtils {
7+
/**
8+
* Returns the cloud assembly template artifact for a stack.
9+
*/
710
public static synthesize(stack: core.Stack, options: core.SynthesisOptions = { }): cxapi.CloudFormationStackArtifact {
811
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
9-
const root = stack.node.root;
10-
11-
// if the root is an app, invoke "synth" to avoid double synthesis
12-
const assembly = root instanceof core.App ? root.synth() : core.ConstructNode.synth(root.node, options);
13-
12+
const assembly = synthesizeApp(stack, options);
1413
return assembly.getStackArtifact(stack.artifactId);
1514
}
1615

@@ -51,10 +50,7 @@ export class SynthUtils {
5150
*/
5251
public static _synthesizeWithNested(stack: core.Stack, options: core.SynthesisOptions = { }): cxapi.CloudFormationStackArtifact | object {
5352
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
54-
const root = stack.node.root;
55-
56-
// if the root is an app, invoke "synth" to avoid double synthesis
57-
const assembly = root instanceof core.App ? root.synth() : core.ConstructNode.synth(root.node, options);
53+
const assembly = synthesizeApp(stack, options);
5854

5955
// if this is a nested stack (it has a parent), then just read the template as a string
6056
if (stack.nestedStackParent) {
@@ -65,6 +61,24 @@ export class SynthUtils {
6561
}
6662
}
6763

64+
/**
65+
* Synthesizes the app in which a stack resides and returns the cloud assembly object.
66+
*/
67+
function synthesizeApp(stack: core.Stack, options: core.SynthesisOptions) {
68+
const root = stack.node.root;
69+
if (!core.Stage.isStage(root)) {
70+
throw new Error('unexpected: all stacks must be part of a Stage or an App');
71+
}
72+
73+
// to support incremental assertions (i.e. "expect(stack).toNotContainSomething(); doSomething(); expect(stack).toContainSomthing()")
74+
const force = true;
75+
76+
return root.synth({
77+
force,
78+
...options,
79+
});
80+
}
81+
6882
export interface SubsetOptions {
6983
/**
7084
* Match all resources of the given type

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

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ const key = api.addApiKey('ApiKey', {
201201
});
202202
```
203203

204+
Existing API keys can also be imported into a CDK app using its id.
205+
206+
```ts
207+
const importedKey = ApiKey.fromApiKeyId(this, 'imported-key', '<api-key-id>');
208+
```
209+
204210
In scenarios where you need to create a single api key and configure rate limiting for it, you can use `RateLimitedApiKey`.
205211
This construct lets you specify rate limiting properties which should be applied only to the api key being created.
206212
The API key created has the specified rate limits, such as quota and throttles, applied.

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

+12
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ export interface ApiKeyProps extends ApiKeyOptions {
8181
* for Method resources that require an Api Key.
8282
*/
8383
export class ApiKey extends Resource implements IApiKey {
84+
85+
/**
86+
* Import an ApiKey by its Id
87+
*/
88+
public static fromApiKeyId(scope: Construct, id: string, apiKeyId: string): IApiKey {
89+
class Import extends Resource implements IApiKey {
90+
public keyId = apiKeyId;
91+
}
92+
93+
return new Import(scope, id);
94+
}
95+
8496
public readonly keyId: string;
8597

8698
constructor(scope: Construct, id: string, props: ApiKeyProps = { }) {

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

+26-26
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ interface LatestDeploymentResourceProps {
123123

124124
class LatestDeploymentResource extends CfnDeployment {
125125
private hashComponents = new Array<any>();
126-
private originalLogicalId: string;
126+
127127
private api: IRestApi;
128128

129129
constructor(scope: Construct, id: string, props: LatestDeploymentResourceProps) {
@@ -133,7 +133,31 @@ class LatestDeploymentResource extends CfnDeployment {
133133
});
134134

135135
this.api = props.restApi;
136-
this.originalLogicalId = Stack.of(this).getLogicalId(this);
136+
137+
const originalLogicalId = Stack.of(this).getLogicalId(this);
138+
139+
this.overrideLogicalId(Lazy.stringValue({ produce: ctx => {
140+
const hash = [ ...this.hashComponents ];
141+
142+
if (this.api instanceof RestApi || this.api instanceof SpecRestApi) { // Ignore IRestApi that are imported
143+
144+
// Add CfnRestApi to the logical id so a new deployment is triggered when any of its properties change.
145+
const cfnRestApiCF = (this.api.node.defaultChild as any)._toCloudFormation();
146+
hash.push(ctx.resolve(cfnRestApiCF));
147+
}
148+
149+
let lid = originalLogicalId;
150+
151+
// if hash components were added to the deployment, we use them to calculate
152+
// a logical ID for the deployment resource.
153+
if (hash.length > 0) {
154+
const md5 = crypto.createHash('md5');
155+
hash.map(x => ctx.resolve(x)).forEach(c => md5.update(JSON.stringify(c)));
156+
lid += md5.digest('hex');
157+
}
158+
159+
return lid;
160+
}}));
137161
}
138162

139163
/**
@@ -149,28 +173,4 @@ class LatestDeploymentResource extends CfnDeployment {
149173

150174
this.hashComponents.push(data);
151175
}
152-
153-
/**
154-
* Hooks into synthesis to calculate a logical ID that hashes all the components
155-
* add via `addToLogicalId`.
156-
*/
157-
protected prepare() {
158-
if (this.api instanceof RestApi || this.api instanceof SpecRestApi) { // Ignore IRestApi that are imported
159-
160-
// Add CfnRestApi to the logical id so a new deployment is triggered when any of its properties change.
161-
const cfnRestApiCF = (this.api.node.defaultChild as any)._toCloudFormation();
162-
this.addToLogicalId(Stack.of(this).resolve(cfnRestApiCF));
163-
}
164-
165-
const stack = Stack.of(this);
166-
167-
// if hash components were added to the deployment, we use them to calculate
168-
// a logical ID for the deployment resource.
169-
if (this.hashComponents.length > 0) {
170-
const md5 = crypto.createHash('md5');
171-
this.hashComponents.map(x => stack.resolve(x)).forEach(c => md5.update(JSON.stringify(c)));
172-
this.overrideLogicalId(this.originalLogicalId + md5.digest('hex'));
173-
}
174-
super.prepare();
175-
}
176176
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"from-method:@aws-cdk/aws-apigateway.Resource",
116116
"duration-prop-type:@aws-cdk/aws-apigateway.QuotaSettings.period",
117117
"duration-prop-type:@aws-cdk/aws-apigateway.ResponseType.INTEGRATION_TIMEOUT",
118-
"from-method:@aws-cdk/aws-apigateway.ApiKey",
119118
"ref-via-interface:@aws-cdk/aws-apigateway.ApiKeyProps.resources",
120119
"props-physical-name:@aws-cdk/aws-apigateway.DeploymentProps",
121120
"props-physical-name:@aws-cdk/aws-apigateway.MethodProps",

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.request-authorizer.expected.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"Properties": {
3737
"Code": {
3838
"S3Bucket": {
39-
"Ref": "AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0S3Bucket316B0B52"
39+
"Ref": "AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0S3BucketD7637C1B"
4040
},
4141
"S3Key": {
4242
"Fn::Join": [
@@ -49,7 +49,7 @@
4949
"Fn::Split": [
5050
"||",
5151
{
52-
"Ref": "AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0S3VersionKey4A4C6C19"
52+
"Ref": "AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0S3VersionKeyC19FD924"
5353
}
5454
]
5555
}
@@ -62,7 +62,7 @@
6262
"Fn::Split": [
6363
"||",
6464
{
65-
"Ref": "AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0S3VersionKey4A4C6C19"
65+
"Ref": "AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0S3VersionKeyC19FD924"
6666
}
6767
]
6868
}
@@ -272,17 +272,17 @@
272272
}
273273
},
274274
"Parameters": {
275-
"AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0S3Bucket316B0B52": {
275+
"AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0S3BucketD7637C1B": {
276276
"Type": "String",
277-
"Description": "S3 bucket for asset \"e7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0\""
277+
"Description": "S3 bucket for asset \"3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0\""
278278
},
279-
"AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0S3VersionKey4A4C6C19": {
279+
"AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0S3VersionKeyC19FD924": {
280280
"Type": "String",
281-
"Description": "S3 key for asset version \"e7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0\""
281+
"Description": "S3 key for asset version \"3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0\""
282282
},
283-
"AssetParameterse7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0ArtifactHash2FE6C4D8": {
283+
"AssetParameters3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0ArtifactHash9DF43F02": {
284284
"Type": "String",
285-
"Description": "Artifact hash for asset \"e7d4044be8659ef3bb40a53a69846d7ca1b2d8e4e4bd36ad8c9d8e69fe3b68a0\""
285+
"Description": "Artifact hash for asset \"3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0\""
286286
}
287287
},
288288
"Outputs": {
@@ -313,4 +313,4 @@
313313
}
314314
}
315315
}
316-
}
316+
}

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"Properties": {
3737
"Code": {
3838
"S3Bucket": {
39-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3Bucket4E51347F"
39+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3Bucket2E551A38"
4040
},
4141
"S3Key": {
4242
"Fn::Join": [
@@ -49,7 +49,7 @@
4949
"Fn::Split": [
5050
"||",
5151
{
52-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166"
52+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621"
5353
}
5454
]
5555
}
@@ -62,7 +62,7 @@
6262
"Fn::Split": [
6363
"||",
6464
{
65-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166"
65+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621"
6666
}
6767
]
6868
}
@@ -281,17 +281,17 @@
281281
}
282282
},
283283
"Parameters": {
284-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3Bucket4E51347F": {
284+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3Bucket2E551A38": {
285285
"Type": "String",
286-
"Description": "S3 bucket for asset \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
286+
"Description": "S3 bucket for asset \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
287287
},
288-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166": {
288+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621": {
289289
"Type": "String",
290-
"Description": "S3 key for asset version \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
290+
"Description": "S3 key for asset version \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
291291
},
292-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eArtifactHash267391ED": {
292+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3ArtifactHashD7A29DA9": {
293293
"Type": "String",
294-
"Description": "Artifact hash for asset \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
294+
"Description": "Artifact hash for asset \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
295295
}
296296
},
297297
"Outputs": {
@@ -322,4 +322,4 @@
322322
}
323323
}
324324
}
325-
}
325+
}

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"Properties": {
3737
"Code": {
3838
"S3Bucket": {
39-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3Bucket4E51347F"
39+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3Bucket2E551A38"
4040
},
4141
"S3Key": {
4242
"Fn::Join": [
@@ -49,7 +49,7 @@
4949
"Fn::Split": [
5050
"||",
5151
{
52-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166"
52+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621"
5353
}
5454
]
5555
}
@@ -62,7 +62,7 @@
6262
"Fn::Split": [
6363
"||",
6464
{
65-
"Ref": "AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166"
65+
"Ref": "AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621"
6666
}
6767
]
6868
}
@@ -272,17 +272,17 @@
272272
}
273273
},
274274
"Parameters": {
275-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3Bucket4E51347F": {
275+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3Bucket2E551A38": {
276276
"Type": "String",
277-
"Description": "S3 bucket for asset \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
277+
"Description": "S3 bucket for asset \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
278278
},
279-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eS3VersionKey707D1166": {
279+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3S3VersionKeyE54FD621": {
280280
"Type": "String",
281-
"Description": "S3 key for asset version \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
281+
"Description": "S3 key for asset version \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
282282
},
283-
"AssetParameters4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181eArtifactHash267391ED": {
283+
"AssetParametersfec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3ArtifactHashD7A29DA9": {
284284
"Type": "String",
285-
"Description": "Artifact hash for asset \"4e547bc3a1a10467cf6503c7845fe1a857e509746b927699a9e3bea8b802181e\""
285+
"Description": "Artifact hash for asset \"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3\""
286286
}
287287
},
288288
"Outputs": {
@@ -313,4 +313,4 @@
313313
}
314314
}
315315
}
316-
}
316+
}

0 commit comments

Comments
 (0)