Skip to content

Commit

Permalink
fix(apigateway): allow overriding apiKeyRequired on methods (#25682)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
iRoachie committed Jun 5, 2023
1 parent 437345e commit ae778cc
Show file tree
Hide file tree
Showing 34 changed files with 2,891 additions and 956 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"version": "22.0.0",
"version": "31.0.0",
"files": {
"fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3": {
"6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0": {
"source": {
"path": "asset.fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.handler",
"path": "asset.6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.handler",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.zip",
"objectKey": "6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"3ef3f0473a2312add1b6eeec16180f638b07d97828baa8745a05728ef3a87074": {
"754a99e7f6ac84befe2ba21bb29f26187bdbfcbde3b2991296ddbcfe55583312": {
"source": {
"path": "TokenAuthorizerInteg.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "3ef3f0473a2312add1b6eeec16180f638b07d97828baa8745a05728ef3a87074.json",
"objectKey": "754a99e7f6ac84befe2ba21bb29f26187bdbfcbde3b2991296ddbcfe55583312.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "fec8e8354e12687c5a4b843b4e269741f53dec634946869b276f7fd1017845c3.zip"
"S3Key": "6ef24b26328dec9135be0bd32fff8f588f9a4564f32df911d1de82cfb78183f0.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -208,7 +208,7 @@
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyRestApiDeploymentB555B5822d29e7cc325d84a3264c658c75a9d43a": {
"MyRestApiDeploymentB555B582e0e53f2547b469b538202de55968eaf0": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
Expand All @@ -229,7 +229,7 @@
"Ref": "MyRestApi2D1F47A9"
},
"DeploymentId": {
"Ref": "MyRestApiDeploymentB555B5822d29e7cc325d84a3264c658c75a9d43a"
"Ref": "MyRestApiDeploymentB555B582e0e53f2547b469b538202de55968eaf0"
},
"StageName": "prod"
},
Expand All @@ -250,6 +250,7 @@
"RestApiId": {
"Ref": "MyRestApi2D1F47A9"
},
"ApiKeyRequired": false,
"AuthorizationType": "NONE",
"Integration": {
"IntegrationResponses": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"version": "22.0.0",
"version": "31.0.0",
"files": {
"382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674": {
"ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3": {
"source": {
"path": "asset.382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.bundle",
"path": "asset.ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.zip",
"objectKey": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"52fafe59d21141477256755bcebd4385222337a65ba87eac0399ec8dc24a2702": {
"a24955fdbaffb6a47fa6e6e5cba21c79c9658ff33a5a2ed4225c206ec217f025": {
"source": {
"path": "apigwtokenauthDefaultTestDeployAssert2CF60E05.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "52fafe59d21141477256755bcebd4385222337a65ba87eac0399ec8dc24a2702.json",
"objectKey": "a24955fdbaffb6a47fa6e6e5cba21c79c9658ff33a5a2ed4225c206ec217f025.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"Payload": "{\"method\":\"GET\",\"authorization\":\"allow\"}"
},
"flattenResponse": "false",
"salt": "1670026030165"
"salt": "1684845809163"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -199,7 +199,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "382ba2a8fd0a13f6782aec5543e465f988f5c100f35ed20f90cd96b8ee53f674.zip"
"S3Key": "ae370e1010629b78f494346f49ceef3ab2875718f20e6c808114e6aa770c7bf3.zip"
},
"Timeout": 120,
"Handler": "index.handler",
Expand Down Expand Up @@ -230,7 +230,7 @@
"Payload": "{\"method\":\"GET\",\"authorization\":\"deny\"}"
},
"flattenResponse": "false",
"salt": "1670026030166"
"salt": "1684845809164"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -269,7 +269,7 @@
"Payload": "{\"method\":\"OPTIONS\"}"
},
"flattenResponse": "false",
"salt": "1670026030167"
"salt": "1684845809164"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down

0 comments on commit ae778cc

Please sign in to comment.