Skip to content

(aws_codepipeline_actions): Wrong type for user_parameters in LambdaInvokeAction #16776

@mebrahimi13

Description

@mebrahimi13

What is the problem?

In LambdaInvokeAction, user_parameters configuration is forced to be of type typing.Mapping[builtins.str, typing.Any], which is then synthesised to the expected CloudFormation string.

The enforced type is more restrictive than that allowed by CloudFormation. This is problematic, since many Lambda function handlers (such as cfn_nag) expect a simple string as input parameter, not a marshalled json object.

Reproduction Steps

import aws_cdk.aws_codepipeline as codepipeline
import aws_cdk.aws_codepipeline_actions as codepipeline_actions
import aws_cdk.pipelines as pipelines

pipeline = pipelines.CdkPipeline(...)
stage = pipeline.add_stage("test")
stage.add_actions(
            codepipeline_actions.LambdaInvokeAction(
                action_name="cfn_nag",
                inputs=[cloud_assembly_artifact],
                lambda_=lambda_.Function.from_function_arn(self, "cfn-nag-lambda", cfn_nag_lambda_arn),
                # user_parameters must be a map, but cfn_nag requires a string
                user_parameters="**/*.template.json",
            ),
)

What did you expect to happen?

The provided string is a valid value type for user_parameters in CloudFormation and should be allowed here.

What actually happened?

The provided snippet fails to synthesise with the following error:

jsii.errors.JSIIError: Expected object type, got "**/*.template.json"

CDK CLI Version

1.122.0

Framework Version

No response

Node.js Version

v12.18.0

OS

macOS Catalina v10.15.7

Language

Python

Language Version

3.9.6

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-codepipeline-actionseffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.feature/enhancementA new API to make things easier or more intuitive. A catch-all for general feature requests.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions