Skip to content

Commit 8dc5190

Browse files
authored
fix(apigateway): duplicate methodResponses if the same array is reused between addMethod calls (#26636)
Adding a new method to an API with `addMethod` and passing `methodOptions.methodResponses` was generating duplicate entries using `StepFunctionsIntegration.startExecution` as integration: For example: ``` const integ = apigw.StepFunctionsIntegration.startExecution(stateMachine, integrationOptions); api.root.addMethod('GET', integ, methodOptions); api.root.addMethod('POST', integ, methodOptions); ``` Would generate (fails on deployment): ``` "MethodResponses": [ { "ResponseParameters": { "method.response.header.Access-Control-Allow-Origin": true }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Empty" }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "400" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "500" }, { "ResponseModels": { "application/json": "Empty" }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "400" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "500" } ], ``` With this fix, it will keep only the specified `methodResponses`. Also, the `integrationResponses` option in `StepFunctionsIntegration.startExecution` was not used by the corresponding `Integration`. This fix will allow to use the specified option value. Closes #26586. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0446e4a commit 8dc5190

12 files changed

+1531
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "33.0.0",
3+
"files": {
4+
"11071ca702d34295486ea4a64c45b64857f4bd23c672fe0895a0b7e753065d77": {
5+
"source": {
6+
"path": "aws-cdk-aws-apigateway-stepfunctions-startexecution.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "11071ca702d34295486ea4a64c45b64857f4bd23c672fe0895a0b7e753065d77.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)