Skip to content

(cli): format of tags in cdk.json is not validated, easy to get wrong #20854

@SydneyUni-Jim

Description

@SydneyUni-Jim

Describe the bug

After adding tags to the local cdk.json, cdk deploy fails with an InvalidParameterType: Expected params.Tags to be an Array from aws-sdk.

Expected Behavior

The synthesized template deploys with the tags in cdk.json.

Current Behavior

❯ cdk deploy

✨  Synthesis time: 3.04s

HelloCdkStack: deploying...
[0%] start: Publishing 774231a5b4dfea162ee0964f8335b364aee003aa142c95fb1c4d3e49537db261:current_account-current_region
[100%] success: Published 774231a5b4dfea162ee0964f8335b364aee003aa142c95fb1c4d3e49537db261:current_account-current_region
HelloCdkStack: creating CloudFormation changeset...

 ❌  HelloCdkStack failed: InvalidParameterType: Expected params.Tags to be an Array
    at ParamValidator.fail (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:50:37)
    at ParamValidator.validateType (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:233:10)
    at ParamValidator.validateList (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:100:14)
    at ParamValidator.validateMember (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:91:21)
    at ParamValidator.validateStructure (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:76:14)
    at ParamValidator.validateMember (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:89:21)
    at ParamValidator.validate2 [as validate] (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/event_listeners.js:132:42)
    at Request.callListeners (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at callNextListener (/opt/homebrew/Cellar/aws-cdk/2.29.0/libexec/lib/node_modules/aws-sdk/lib/sequential_executor.js:96:12) {
  code: 'InvalidParameterType',
  time: 2022-06-24T02:18:15.714Z
}

Expected params.Tags to be an Array

Reproduction Steps

  1. mkdir hello-cdk
  2. cd hello-cdk
  3. cdk init app --language typescript
  4. cdk deploy

So far this works.

  1. Replace cdk.json with this cdk.json.
  2. cdk deploy

This fails.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.29.0 (build 47d7ec4)

Framework Version

No response

Node.js Version

v16.15.1

OS

macOS 12.4 arm64

Language

Typescript

Language Version

4.7.4

Other information

Documentation reference: https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-config

tags - JSON object containing tags (key-value pairs) for the stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions