Skip to content

apigateway: Multiple StepFunctionsIntegrations with options lead to "Property MethodResponses contains duplicate values" #26586

@boenhoff

Description

@boenhoff

Describe the bug

Using the StepFunctionsIntegration.startExecution() integration with API Gateway with cors options (see reproduction steps) works, as long as only one method has the integration with options.

If a second method uses the same options you will get the error
The stack named TestStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Property MethodResponses contains duplicate values., Property MethodResponses contains duplicate values. and in the cdk.out it generates multiple ResponseModels.

Expected Behavior

Multiple methods with the StepFunctionsIntegration.startExecution() creates methods with individual options.

Current Behavior

❌ Deployment failed: Error: The stack named TestStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Property MethodResponses contains duplicate values., Property MethodResponses contains duplicate values.
    at FullCloudFormationDeployment.monitorDeployment (/opt/homebrew/Cellar/aws-cdk/2.89.0/libexec/lib/node_modules/aws-cdk/lib/index.js:426:10236)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/opt/homebrew/Cellar/aws-cdk/2.89.0/libexec/lib/node_modules/aws-cdk/lib/index.js:429:153307)
    at async /opt/homebrew/Cellar/aws-cdk/2.89.0/libexec/lib/node_modules/aws-cdk/lib/index.js:429:136985

The stack named TestStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Property MethodResponses contains duplicate values., Property MethodResponses contains duplicate values.

Reproduction Steps

  • create a new CDK project dk init app --language typescript
  • insert the following Code in the Stack
  • deploy with cdk deploy --require-approval never
        const methodOptions = {
            methodResponses: [
                {
                    statusCode: '200',
                    responseParameters: {
                        'method.response.header.Access-Control-Allow-Origin': true,
                    }
                },
            ]
        }

        const integrationOptions = {
            integrationResponses: [
                {
                    responseParameters: {
                        'method.response.header.Access-Control-Allow-Origin': "'*'",
                    },
                    statusCode: '200'
                }
            ]
        }
        const api = new RestApi(this, 'api');
        const machine = new StateMachine(this, 'machine', {
            stateMachineType: StateMachineType.EXPRESS,
            definitionBody: DefinitionBody.fromChainable(new Pass(this, 'Pass'))
        })
        // uncomment the following line and comment out the line after that to make it running - but without the cors options
        // api.root.addMethod('POST', StepFunctionsIntegration.startExecution(machine))
        api.root.addMethod('POST', StepFunctionsIntegration.startExecution(machine, integrationOptions), methodOptions)
        api.root.addMethod('GET', StepFunctionsIntegration.startExecution(machine, integrationOptions), methodOptions)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.89.0 (build 2ad6683)

Framework Version

No response

Node.js Version

v20.5.0

OS

macOS 13.5

Language

Typescript

Language Version

TypeScript (5.1.6)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apigatewayRelated to Amazon API GatewaybugThis issue is a bug.effort/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions