AWS CDK AWS Systems Manager (SSM) Construct Library (v1)

1.204.0 · deprecated · verified Thu Apr 16

The `aws-cdk-aws-ssm` package provides CDK constructs for provisioning AWS Systems Manager (SSM) resources such as Parameter Store parameters within your AWS Cloud Development Kit applications. This specific package is part of AWS CDK v1, which reached End-of-Support on June 1, 2023. The AWS CDK project is active with weekly updates for v2, which consolidates all stable constructs into a single `aws-cdk-lib` package. [2, 4, 15, 29]

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a new String Parameter and how to look up an existing String Parameter using AWS CDK v2. It defines a simple stack that provisions an SSM parameter and then references another (presumably pre-existing) parameter. For v1, the imports would be `import aws_cdk.aws_ssm as ssm` instead of `from aws_cdk import aws_ssm` and `ssm.StringParameter` etc. [3, 13, 16, 25]

import os
import aws_cdk as cdk
from constructs import Construct
from aws_cdk import aws_ssm

class MySsmStack(cdk.Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # Create a new String Parameter in SSM Parameter Store
        aws_ssm.StringParameter(self, "MyParameter",
            parameter_name="/my/app/config/value",
            string_value="MyParameterValue",
            description="A parameter for my application configuration",
            tier=aws_ssm.ParameterTier.STANDARD
        )

        # Look up an existing String Parameter at synthesis time
        # Note: This will perform an AWS API call during 'cdk synth'
        # and cache the value in cdk.context.json. [3, 22]
        existing_param_value = aws_ssm.StringParameter.value_from_lookup(
            self, "ExistingParameterLookup", "/path/to/existing/param"
        )

        # Output the value (for demonstration purposes)
        cdk.CfnOutput(self, "ExistingParameterOutput", value=existing_param_value)

app = cdk.App()
MySsmStack(app, "MySsmStack",
    env=cdk.Environment(
        account=os.environ.get('CDK_DEFAULT_ACCOUNT', ''),
        region=os.environ.get('CDK_DEFAULT_REGION', '')
    )
)
app.synth()

view raw JSON →