Skip to content

(ssm): can not import parameter name from another stack #17094

@mariusingjer

Description

@mariusingjer

What is the problem?

cdk generates input parameters in a stack when importing parameter store values.

Reproduction Steps

    configSqs = (scope: cdk.Construct) =>
        ssm.StringParameter.fromStringParameterAttributes(
            scope,
            'import-sqs-string-param',
            {
                simpleName: true,
                parameterName: cdk.Fn.importValue('some-exported-value-holding-the-param-name'),
            }
        );

        const sqsConfig = configSqs(this);
        sqsConfig.grantRead(this.ingestLambda);

This renders perfectly in terms of IAM:

            {
              "Action": [
                "ssm:DescribeParameters",
                "ssm:GetParameters",
                "ssm:GetParameter",
                "ssm:GetParameterHistory"
              ],
              "Effect": "Allow",
              "Resource": {
                "Fn::Join": [
                  "",
                  [
                    "arn:",
                    {
                      "Ref": "AWS::Partition"
                    },
                    ":ssm:eu-west-1:123456789012:parameter/",
                    {
                      "Fn::ImportValue": "some-exported-value-holding-the-param-name"
                    }
                  ]
                ]
              }
            }

But i also generates a parameter construct in the stack (I have no idea why):

  "Parameters": {
    "importsqsstringparamParameter": {
      "Type": "AWS::SSM::Parameter::Value<String>",
      "Default": {
        "Fn::ImportValue": "some-exported-value-holding-the-param-name"
      }
    },

What did you expect to happen?

CDK not to create input parameters on the CF-stack, Why does it create an input parameter to the cloudformation stack?

PS

I know you can explicity reference the parameter cross stack, but then you get into the automagically creation of exports problem

What actually happened?

CDK creates input parameters on the CF-stack which breaks when deploying with: "Template format error: Every Default member must be a string".

CDK CLI Version

1.124.0

Framework Version

No response

Node.js Version

12

OS

ubuntu

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ssmRelated to AWS Systems ManagerbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions