Skip to content

aws-ssm: StringParameter Doesn't support data_type=ssm.ParameterType.AWS_EC2_IMAGE_ID #16806

@scottbisker

Description

@scottbisker

What is the problem?

When trying to create a StringParameter of type ssm.ParameterType.AWS_EC2_IMAGE_ID, CDK throws the following error.

1 validation error detected: Value 'AWS::EC2::Image::Id' at 'type' failed to satisfy constraint: Member must satisfy enum value set: [SecureString, StringList, String]. (Service: AmazonSSM; Status Code: 400; Error Code: Validat
ionException; Request ID: 2c97174a-045e-4451-be0a-b61d8f5a2fe8; Proxy: null)

Reproduction Steps

image_parameter = ssm.StringParameter(self, 'ImageBuilderAMI',
type = ssm.ParameterType.AWS_EC2_IMAGE_ID,
parameter_name = '/ec2-imagebuilder/latest',
description = "Latest AMI Image",
string_value = self.node.try_get_context(env_context)["LinuxAmi"]
)

What did you expect to happen?

Since it is StringParameter, there should be an additional value passed in the constructor data_type.

This is a working version using ssm.CfnParameter.

    image_parameter = ssm.CfnParameter(self, "ImageBuilderAMI",
        type = "String",
        data_type = "aws:ec2:image",
        name = "/ec2-imagebuilder/latest",
        description = "Latest AMI Image",
        value = self.node.try_get_context(env_context)["LinuxAmi"] 
        )

What actually happened?

Stack failed to create.

1 validation error detected: Value 'AWS::EC2::Image::Id' at 'type' failed to satisfy constraint: Member must satisfy enum value set: [SecureString, StringList, String]. (Service: AmazonSSM; Status Code: 400; Error Code: Validat
ionException; Request ID: 2c97174a-045e-4451-be0a-b61d8f5a2fe8; Proxy: null)

CDK CLI Version

1.24.0

Framework Version

No response

Node.js Version

14.16.1

OS

MacOS Big Sur

Language

Python

Language Version

3.9

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