Skip to content

(ssm): StringListParameter generate wrong CF template and does not work unlike StringParameter #14364

@sunshineo

Description

@sunshineo

Using StringListParameter produced a piece of CF template code that does not work. The code follows a different pattern compare to the working StringParameter. If use a workaround to make it follow the same pattern then it works.

Reproduction Steps

    const securityGroupId = ssm.StringParameter.fromStringParameterName(this, 'EksClusterSecurityGroupId', 'EksClusterSecurityGroupId').stringValue
    const subnetIds = ssm.StringListParameter.fromStringListParameterName(this, 'EksVpcSubnetIdsList', 'EksVpcSubnetIdsList').stringListValue
    const subnetGroup = new ec.CfnSubnetGroup(this, 'RedisSubnetGroup', {
        subnetIds: subnetIds,
        description: 'SubnetGrop for GraphQL Redis'
    });

    const redis = new ec.CfnReplicationGroup(this, 'graphql-redis', {
      engine: 'redis',
      replicationGroupDescription: 'Redis replication group for GraphQL',
      securityGroupIds: [securityGroupId],
      cacheSubnetGroupName: subnetGroup.ref,
    })

The part of generated CF template relevant:
The StringParameter works

...
Parameters:
  EksClusterSecurityGroupIdParameter:
    Type: AWS::SSM::Parameter::Value<String>
    Default: EksClusterSecurityGroupId
...
    SecurityGroupIds:
        - Ref: EksClusterSecurityGroupIdParameter
...

The StringListParameter part did not work:

    SubnetIds:
        Fn::Split:
          - ","
          - "{{resolve:ssm:EksVpcSubnetIdsList}}"

What did you expect to happen?

Expect to have the same behavior for String and StringList parameters. Expect the CF template looks like this:

Parameters:
  EksClusterSecurityGroupIdParameter:
    Type: AWS::SSM::Parameter::Value<String>
    Default: EksClusterSecurityGroupId
  EksVpcSubnetIdsListParameter:
    Type: AWS::SSM::Parameter::Value<List<String>>
    Default: EksVpcSubnetIdsList
...
      SecurityGroupIds:
        - Ref: EksClusterSecurityGroupIdParameter
...
      SubnetIds:
        Ref: EksVpcSubnetIdsListParameter

What actually happened?

Error when run cdk deploy:

4:07:02 PM | UPDATE_FAILED        | AWS::ElastiCache::SubnetGroup      | RedisSubnetGroup
Some input subnets in :[subnet-0a98619236902dd41,subnet-03dc3c44f20a5b2fd,subnet-0f777749ecdf46d39,subnet-07b25009783baa9c9] are invalid. (Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterValue; Request ID: f8765da2-a0a1-4b4e-b7f6-a4afe8b09780; Proxy: null)

Environment

  • CDK CLI Version : 1.100.0
  • Framework Version: 1.100.0
  • Node.js Version:
  • OS :
  • Language (Version):

Other

There is a workaround to manually create a Parameter

const eksVpcSubnetIdsListParameter = new cdk.CfnParameter(this, 'subnetIds', {
      type: 'AWS::SSM::Parameter::Value<List<String>>',
      default: 'EksVpcSubnetIdsList',
    })
const subnetGroup = new ec.CfnSubnetGroup(this, 'RedisSubnetGroup', {
        subnetIds: eksVpcSubnetIdsListParameter.valueAsList,
        description: 'SubnetGrop for GraphQL Redis'
      });

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ssmRelated to AWS Systems ManagerbugThis 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