Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDK to CFN template is serializing incorrectly #1722

Closed
srivastavr opened this issue Jun 22, 2023 · 3 comments
Closed

CDK to CFN template is serializing incorrectly #1722

srivastavr opened this issue Jun 22, 2023 · 3 comments
Labels

Comments

@srivastavr
Copy link

Name of the resource

AWS::StepFunctions::StateMachine

Resource Name

No response

Issue Description

Hi,

We are passing array of array in payload from step function to a lambda function, below is the sample code

            lambdaFunction: serviceCallHandler,
            resultSelector: resultSelector,
            resultPath: resultPath,
            payload: TaskInput.fromObject({
                key1: [
                    [
                        {
                            key2: {
                                key3: 'value1',
                            },
                            key4: [
                                [
                                    {
                                        key5: {
                                            key6: 'value2',
                                        },
                                    },
                                ],
                            ],
                        },
                    ],
                ],
            }),
        }

but after building, the cloud formation template converts this into array of objects with 0 index at places which is incorrect.

like this

 {
        "Ref": "AWS::Partition"
       },
       ":states:::lambda:invoke\",\"Parameters\":{\"FunctionName\":\"",
       {
        "Fn::GetAtt": [
         "servicecallhandler3F6E12B2",
         "Arn"
        ]
       },
       "\",\"Payload\":{\"key1\":[{\"0\":{\"key2\":{\"key3\":\"value1\"},\"key4\":[{\"0\":{\"key5\":{\"key6\":\"value2\"}}}]}}]}}}

Expected Behavior

 {
        "Ref": "AWS::Partition"
       },
       ":states:::lambda:invoke\",\"Parameters\":{\"FunctionName\":\"",
       {
        "Fn::GetAtt": [
         "servicecallhandler3F6E12B2",
         "Arn"
        ]
       },
       "\",\"Payload\":{\"key1\":[[{\"key2\":{\"key3\":\"value1\"},\"key4\":[[{\"key5\":{\"key6\":\"value2\"}]}]}}]]}}

Observed Behavior

{
        "Ref": "AWS::Partition"
       },
       ":states:::lambda:invoke\",\"Parameters\":{\"FunctionName\":\"",
       {
        "Fn::GetAtt": [
         "servicecallhandler3F6E12B2",
         "Arn"
        ]
       },
       "\",\"Payload\":{\"key1\":[{\"0\":{\"key2\":{\"key3\":\"value1\"},\"key4\":[{\"0\":{\"key5\":{\"key6\":\"value2\"}}}]}}]}}}

Test Cases

NA

Other Details

No response

@srivastavr srivastavr added the bug label Jun 22, 2023
@benbridts
Copy link

@srivastavr You might want to report this in the CDK repository, this doesn't look like a bug on the CloudFormation side.

See https://github.com/aws/aws-cdk#getting-help

@evscott
Copy link

evscott commented Jun 22, 2023

Like @benbridts said, this doesn't look like a bug in CloudFormation, the serialization is implemented in CDK:

https://github.com/aws/aws-cdk/blob/a79794e3f2609e6efa5cf659eec039964a8ad61c/packages/aws-cdk-lib/aws-stepfunctions/lib/input.ts#L21-L23

It also doesn't look like the issue is in Step Functions' TaskInput class: https://www.mycompiler.io/view/ATeYKGae0NT

@srivastavr
Copy link
Author

Opened a issue at CDK(aws/aws-cdk#26111)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants