Aws-cdk: ssm.StringListParameter does not have version parameter

Created on 8 Aug 2019  路  4Comments  路  Source: aws/aws-cdk

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • [x] :beetle: bug report
    • [ ] :rocket: feature request
    • [ ] :books: construct library gap
    • [ ] :phone: security issue or vulnerability => Please see policy
    • [ ] :question: support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a :beetle:bug:beetle:: Please provide the steps to reproduce

At the moment StringListParameter class has fromStringListParameterName parameter is rendered using CfnDynamicReference

As a result ssm.StringListParameter.string_list_value creates AWS Cloudformation code block like this:

            {
              "Fn::Split": [
                ",",
                "{{resolve:ssm:parameter-name}}"
              ]
            }
  • What is the expected behavior (or behavior of feature suggested)?
    Accoring to AWS CloudFormation documentation in block SSM Parameters:
    > For SSM Parameters, the reference-key segment is composed of the parameter name and version number. Use the following pattern:
    > '{{resolve:ssm:parameter-name:version}}'
    > Your reference must adhere to the following regular expression pattern for parameter-name and version:
    > '{{resolve:ssm:[a-zA-Z0-9_.-/]+:\d+}}'

That means that StringListParameter should have parameter-name and version. At the moment aws cdk renders parameter-name only.

  • What is the motivation / use case for changing the behavior or adding this feature?

AWS Cloudformation shows Validation error
ValidationError: Incorrect format is used in the following SSM reference: [{{resolve:ssm:parameter-name}}] Incorrect format is used in the following SSM reference: [{{resolve:ssm:parameter-name}}]

  • Please tell us about your environment:

    • CDK CLI Version: 1.3.0
    • Module Version: 1.3.0
    • OS: [Ubuntu]
    • Language: [Python]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

ValidationError: Incorrect format is used in the following SSM reference: [{{resolve:ssm:parameter-name}}]
    at Request.extractError (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/home/user/.nvm/versions/node/v10.16.0/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
@aws-cdaws-ssm efforsmall feature-request p1

Most helpful comment

I ran into this as well. It makes using StringListParameter in CDK impossible, currently. Any plan to fix this?

The workaround for me is to use a StringParameter with comma-separated values and to the splitting and joining myself.

All 4 comments

This isn't just a python issue, happening with typescript as well. I tried the following which does give me a valid cloudformation template but this wont work due to limitiations and buggy behaviour with how cloudformation executes rather than aws-cdk

const lambda = new Function(this, 'Lambda', {...}) // No need to set vpc here. Added benifit is actuall less code
const cfnLambda = lambda.node.defaultChild as CfnFunction;
cfnLambda.vpcConfig = {
    securityGroupIds: [vpcSecurityGroup.stringValue],
    subnetIds: Fn.split(',', new CfnDynamicReference(CfnDynamicReferenceService.SSM, `${vpcSubnetId.parameterName}:1`).toString()),
}; // where `:1` is assigning the version i wanted

It's been a year, and it appears we cannot use StringListParameter yet.

What is the workaround?

If this cannot be fixed please annotate the documentation for StringListParameter and say it cannot be used.

I ran into this as well. It makes using StringListParameter in CDK impossible, currently. Any plan to fix this?

The workaround for me is to use a StringParameter with comma-separated values and to the splitting and joining myself.

Just ran into this problem. So :+1: in favor of a solution.
I would try and fix this myself. Any hint on were/how to get going @MrArnoldPalmer ?

Was this page helpful?
0 / 5 - 0 ratings