Package software.amazon.awscdk.services.ssm


@Stability(Stable) @Deprecated package software.amazon.awscdk.services.ssm
Deprecated.

AWS Systems Manager Construct Library

---

End-of-Support

AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.

For more information on how to migrate, see the Migrating to AWS CDK v2 guide.


This module is part of the AWS Cloud Development Kit project.

Installation

Install the module:

 $ npm i @aws-cdk/aws-ssm
 

Import it into your code:

 import software.amazon.awscdk.services.ssm.*;
 

Using existing SSM Parameters in your CDK app

You can reference existing SSM Parameter Store values that you want to use in your CDK app by using ssm.StringParameter.fromStringParameterAttributes:

 // Retrieve the latest value of the non-secret parameter
 // with name "/My/String/Parameter".
 String stringValue = StringParameter.fromStringParameterAttributes(this, "MyValue", StringParameterAttributes.builder()
         .parameterName("/My/Public/Parameter")
         .build()).getStringValue();
 String stringValueVersionFromToken = StringParameter.fromStringParameterAttributes(this, "MyValueVersionFromToken", StringParameterAttributes.builder()
         .parameterName("/My/Public/Parameter")
         // parameter version from token
         .version(parameterVersion)
         .build()).getStringValue();
 
 // Retrieve a specific version of the secret (SecureString) parameter.
 // 'version' is always required.
 IStringParameter secretValue = StringParameter.fromSecureStringParameterAttributes(this, "MySecureValue", SecureStringParameterAttributes.builder()
         .parameterName("/My/Secret/Parameter")
         .version(5)
         .build());
 IStringParameter secretValueVersionFromToken = StringParameter.fromSecureStringParameterAttributes(this, "MySecureValueVersionFromToken", SecureStringParameterAttributes.builder()
         .parameterName("/My/Secret/Parameter")
         // parameter version from token
         .version(parameterVersion)
         .build());
 

Creating new SSM Parameters in your CDK app

You can create either ssm.StringParameter or ssm.StringListParameters in a CDK app. These are public (not secret) values. Parameters of type SecureString cannot be created directly from a CDK application; if you want to provision secrets automatically, use Secrets Manager Secrets (see the @aws-cdk/aws-secretsmanager package).

 StringParameter.Builder.create(this, "Parameter")
         .allowedPattern(".*")
         .description("The value Foo")
         .parameterName("FooParameter")
         .stringValue("Foo")
         .tier(ParameterTier.ADVANCED)
         .build();
 

 // Create a new SSM Parameter holding a String
 StringParameter param = StringParameter.Builder.create(stack, "StringParameter")
         // description: 'Some user-friendly description',
         // name: 'ParameterName',
         .stringValue("Initial parameter value")
         .build();
 
 // Grant read access to some Role
 param.grantRead(role);
 
 // Create a new SSM Parameter holding a StringList
 StringListParameter listParameter = StringListParameter.Builder.create(stack, "StringListParameter")
         // description: 'Some user-friendly description',
         // name: 'ParameterName',
         .stringListValue(List.of("Initial parameter value A", "Initial parameter value B"))
         .build();
 

When specifying an allowedPattern, the values provided as string literals are validated against the pattern and an exception is raised if a value provided does not comply. Deprecated: AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2. For more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html