Skip to content

(ssm): Retrieve secure string without version number #17091

@fire015

Description

@fire015

General Issue

Ability to retrieve secure string without version number

The Question

I am using ECS fargate and the secrets property to retrieve secret env vars from SSM.

    new ApplicationLoadBalancedFargateService(this, "ECSService", {
      taskImageOptions: {
        secrets: {
          API_KEY: this.getSecret("API_KEY", 1),
        },
      },
    });

  private getSecret(parameterName: string, version: number): ecs.Secret {
    return ecs.Secret.fromSsmParameter(
      ssm.StringParameter.fromSecureStringParameterAttributes(this, `SecretParameter-${parameterName}`, { parameterName, version })
    );
  }

The problem is you have to define the version number to retrieve a secure string (unlike a regular string) and this gets difficult when you deploy the same stack to different environments and the version of the secret may differ between environments.

Is there a better way of doing this or can I suggest this as a new feature request? It's not clear why you don't have to define a version for a regular string but you do for a secure one...

CDK CLI Version

1.107.0

Framework Version

No response

Node.js Version

12

OS

No response

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ssmRelated to AWS Systems Managerfeature-requestA feature should be added or improved.feature/enhancementA new API to make things easier or more intuitive. A catch-all for general feature requests.needs-cfnThis issue is waiting on changes to CloudFormation before it can be addressed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions