Skip to content

Commit ae778cc

Browse files
authored
fix(apigateway): allow overriding apiKeyRequired on methods (#25682)
RestApi has the ability to set the apiKeyRequired option for all methods via defaultMethodOptions. Setting this option on a method should override the value set in defaultMethodOptions, but it doesn't work. This commit fixes the behaviour and adds a test. Mentioned in #8827 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 437345e commit ae778cc

File tree

34 files changed

+2891
-956
lines changed

34 files changed

+2891
-956
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.token-authorizer.js.snapshot/TokenAuthorizerInteg.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "22.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3": {
4+
"6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0": {
55
"source": {
6-
"path": "asset.fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.handler",
6+
"path": "asset.6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.handler",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.zip",
12+
"objectKey": "6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"3ef3f0473a2312add1b6eeec16180f638b07d97828baa8745a05728ef3a87074": {
17+
"754a99e7f6ac84befe2ba21bb29f26187bdbfcbde3b2991296ddbcfe55583312": {
1818
"source": {
1919
"path": "TokenAuthorizerInteg.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "3ef3f0473a2312add1b6eeec16180f638b07d97828baa8745a05728ef3a87074.json",
25+
"objectKey": "754a99e7f6ac84befe2ba21bb29f26187bdbfcbde3b2991296ddbcfe55583312.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.token-authorizer.js.snapshot/TokenAuthorizerInteg.template.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"S3Bucket": {
3939
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
4040
},
41-
"S3Key": "fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.zip"
41+
"S3Key": "6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.zip"
4242
},
4343
"Role": {
4444
"Fn::GetAtt": [
@@ -208,7 +208,7 @@
208208
"UpdateReplacePolicy": "Retain",
209209
"DeletionPolicy": "Retain"
210210
},
211-
"MyRestApiDeploymentB555B5822d29e7cc325d84a3264c658c75a9d43a": {
211+
"MyRestApiDeploymentB555B582e0e53f2547b469b538202de55968eaf0": {
212212
"Type": "AWS::ApiGateway::Deployment",
213213
"Properties": {
214214
"RestApiId": {
@@ -229,7 +229,7 @@
229229
"Ref": "MyRestApi2D1F47A9"
230230
},
231231
"DeploymentId": {
232-
"Ref": "MyRestApiDeploymentB555B5822d29e7cc325d84a3264c658c75a9d43a"
232+
"Ref": "MyRestApiDeploymentB555B582e0e53f2547b469b538202de55968eaf0"
233233
},
234234
"StageName": "prod"
235235
},
@@ -250,6 +250,7 @@
250250
"RestApiId": {
251251
"Ref": "MyRestApi2D1F47A9"
252252
},
253+
"ApiKeyRequired": false,
253254
"AuthorizationType": "NONE",
254255
"Integration": {
255256
"IntegrationResponses": [

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.token-authorizer.js.snapshot/apigwtokenauthDefaultTestDeployAssert2CF60E05.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "22.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674": {
4+
"ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3": {
55
"source": {
6-
"path": "asset.382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.bundle",
6+
"path": "asset.ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.bundle",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.zip",
12+
"objectKey": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"52fafe59d21141477256755bcebd4385222337a65ba87eac0399ec8dc24a2702": {
17+
"a24955fdbaffb6a47fa6e6e5cba21c79c9658ff33a5a2ed4225c206ec217f025": {
1818
"source": {
1919
"path": "apigwtokenauthDefaultTestDeployAssert2CF60E05.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "52fafe59d21141477256755bcebd4385222337a65ba87eac0399ec8dc24a2702.json",
25+
"objectKey": "a24955fdbaffb6a47fa6e6e5cba21c79c9658ff33a5a2ed4225c206ec217f025.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.token-authorizer.js.snapshot/apigwtokenauthDefaultTestDeployAssert2CF60E05.template.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"Payload": "{\"method\":\"GET\",\"authorization\":\"allow\"}"
2020
},
2121
"flattenResponse": "false",
22-
"salt": "1670026030165"
22+
"salt": "1684845809163"
2323
},
2424
"UpdateReplacePolicy": "Delete",
2525
"DeletionPolicy": "Delete"
@@ -199,7 +199,7 @@
199199
"S3Bucket": {
200200
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
201201
},
202-
"S3Key": "382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.zip"
202+
"S3Key": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip"
203203
},
204204
"Timeout": 120,
205205
"Handler": "index.handler",
@@ -230,7 +230,7 @@
230230
"Payload": "{\"method\":\"GET\",\"authorization\":\"deny\"}"
231231
},
232232
"flattenResponse": "false",
233-
"salt": "1670026030166"
233+
"salt": "1684845809164"
234234
},
235235
"UpdateReplacePolicy": "Delete",
236236
"DeletionPolicy": "Delete"
@@ -269,7 +269,7 @@
269269
"Payload": "{\"method\":\"OPTIONS\"}"
270270
},
271271
"flattenResponse": "false",
272-
"salt": "1670026030167"
272+
"salt": "1684845809164"
273273
},
274274
"UpdateReplacePolicy": "Delete",
275275
"DeletionPolicy": "Delete"

0 commit comments

Comments
 (0)