Namespace Amazon.CDK.AWS.SSM
AWS Systems Manager Construct Library
---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:
using Amazon.CDK.AWS.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".
var stringValue = StringParameter.FromStringParameterAttributes(this, "MyValue", new StringParameterAttributes {
ParameterName = "/My/Public/Parameter"
}).StringValue;
var stringValueVersionFromToken = StringParameter.FromStringParameterAttributes(this, "MyValueVersionFromToken", new StringParameterAttributes {
ParameterName = "/My/Public/Parameter",
// parameter version from token
Version = parameterVersion
}).StringValue;
// Retrieve a specific version of the secret (SecureString) parameter.
// 'version' is always required.
var secretValue = StringParameter.FromSecureStringParameterAttributes(this, "MySecureValue", new SecureStringParameterAttributes {
ParameterName = "/My/Secret/Parameter",
Version = 5
});
var secretValueVersionFromToken = StringParameter.FromSecureStringParameterAttributes(this, "MySecureValueVersionFromToken", new SecureStringParameterAttributes {
ParameterName = "/My/Secret/Parameter",
// parameter version from token
Version = parameterVersion
});
Creating new SSM Parameters in your CDK app
You can create either ssm.StringParameter
or ssm.StringListParameter
s 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).
new StringParameter(this, "Parameter", new StringParameterProps {
AllowedPattern = ".*",
Description = "The value Foo",
ParameterName = "FooParameter",
StringValue = "Foo",
Tier = ParameterTier.ADVANCED
});
// Create a new SSM Parameter holding a String
var param = new StringParameter(stack, "StringParameter", new StringParameterProps {
// description: 'Some user-friendly description',
// name: 'ParameterName',
StringValue = "Initial parameter value"
});
// Grant read access to some Role
param.GrantRead(role);
// Create a new SSM Parameter holding a StringList
var listParameter = new StringListParameter(stack, "StringListParameter", new StringListParameterProps {
// description: 'Some user-friendly description',
// name: 'ParameterName',
StringListValue = new [] { "Initial parameter value A", "Initial parameter value B" }
});
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.
Classes
CfnAssociation | A CloudFormation |
CfnAssociation.InstanceAssociationOutputLocationProperty |
|
CfnAssociation.S3OutputLocationProperty |
|
CfnAssociation.TargetProperty |
|
CfnAssociationProps | Properties for defining a |
CfnDocument | A CloudFormation |
CfnDocument.AttachmentsSourceProperty | Identifying information about a document attachment, including the file name and a key-value pair that identifies the location of an attachment to a document. |
CfnDocument.DocumentRequiresProperty | An SSM document required by the current document. |
CfnDocumentProps | Properties for defining a |
CfnMaintenanceWindow | A CloudFormation |
CfnMaintenanceWindowProps | Properties for defining a |
CfnMaintenanceWindowTarget | A CloudFormation |
CfnMaintenanceWindowTarget.TargetsProperty | The |
CfnMaintenanceWindowTargetProps | Properties for defining a |
CfnMaintenanceWindowTask | A CloudFormation |
CfnMaintenanceWindowTask.CloudWatchOutputConfigProperty | Configuration options for sending command output to Amazon CloudWatch Logs. |
CfnMaintenanceWindowTask.LoggingInfoProperty | The |
CfnMaintenanceWindowTask.MaintenanceWindowAutomationParametersProperty | The |
CfnMaintenanceWindowTask.MaintenanceWindowLambdaParametersProperty | The |
CfnMaintenanceWindowTask.MaintenanceWindowRunCommandParametersProperty | The |
CfnMaintenanceWindowTask.MaintenanceWindowStepFunctionsParametersProperty | The |
CfnMaintenanceWindowTask.NotificationConfigProperty | The |
CfnMaintenanceWindowTask.TargetProperty | The |
CfnMaintenanceWindowTask.TaskInvocationParametersProperty | The |
CfnMaintenanceWindowTaskProps | Properties for defining a |
CfnParameter | A CloudFormation |
CfnParameterProps | Properties for defining a |
CfnPatchBaseline | A CloudFormation |
CfnPatchBaseline.PatchFilterGroupProperty | The |
CfnPatchBaseline.PatchFilterProperty | The |
CfnPatchBaseline.PatchSourceProperty |
|
CfnPatchBaseline.RuleGroupProperty | The |
CfnPatchBaseline.RuleProperty | The |
CfnPatchBaselineProps | Properties for defining a |
CfnResourceDataSync | A CloudFormation |
CfnResourceDataSync.AwsOrganizationsSourceProperty | Information about the |
CfnResourceDataSync.S3DestinationProperty | Information about the target S3 bucket for the resource data sync. |
CfnResourceDataSync.SyncSourceProperty | Information about the source of the data included in the resource data sync. |
CfnResourceDataSyncProps | Properties for defining a |
CfnResourcePolicy | A CloudFormation |
CfnResourcePolicyProps | Properties for defining a |
CommonStringParameterAttributes | Common attributes for string parameters. |
ParameterDataType | SSM parameter data type. |
ParameterOptions | Properties needed to create a new SSM Parameter. |
ParameterTier | SSM parameter tier. |
ParameterType | SSM parameter type. |
SecureStringParameterAttributes | Attributes for secure string parameters. |
StringListParameter | Creates a new StringList SSM Parameter. |
StringListParameterProps | Properties needed to create a StringList SSM Parameter. |
StringParameter | Creates a new String SSM Parameter. |
StringParameterAttributes | Attributes for parameters of various types of string. |
StringParameterProps | Properties needed to create a String SSM parameter. |
Interfaces
CfnAssociation.IInstanceAssociationOutputLocationProperty |
|
CfnAssociation.IS3OutputLocationProperty |
|
CfnAssociation.ITargetProperty |
|
CfnDocument.IAttachmentsSourceProperty | Identifying information about a document attachment, including the file name and a key-value pair that identifies the location of an attachment to a document. |
CfnDocument.IDocumentRequiresProperty | An SSM document required by the current document. |
CfnMaintenanceWindowTarget.ITargetsProperty | The |
CfnMaintenanceWindowTask.ICloudWatchOutputConfigProperty | Configuration options for sending command output to Amazon CloudWatch Logs. |
CfnMaintenanceWindowTask.ILoggingInfoProperty | The |
CfnMaintenanceWindowTask.IMaintenanceWindowAutomationParametersProperty | The |
CfnMaintenanceWindowTask.IMaintenanceWindowLambdaParametersProperty | The |
CfnMaintenanceWindowTask.IMaintenanceWindowRunCommandParametersProperty | The |
CfnMaintenanceWindowTask.IMaintenanceWindowStepFunctionsParametersProperty | The |
CfnMaintenanceWindowTask.INotificationConfigProperty | The |
CfnMaintenanceWindowTask.ITargetProperty | The |
CfnMaintenanceWindowTask.ITaskInvocationParametersProperty | The |
CfnPatchBaseline.IPatchFilterGroupProperty | The |
CfnPatchBaseline.IPatchFilterProperty | The |
CfnPatchBaseline.IPatchSourceProperty |
|
CfnPatchBaseline.IRuleGroupProperty | The |
CfnPatchBaseline.IRuleProperty | The |
CfnResourceDataSync.IAwsOrganizationsSourceProperty | Information about the |
CfnResourceDataSync.IS3DestinationProperty | Information about the target S3 bucket for the resource data sync. |
CfnResourceDataSync.ISyncSourceProperty | Information about the source of the data included in the resource data sync. |
ICfnAssociationProps | Properties for defining a |
ICfnDocumentProps | Properties for defining a |
ICfnMaintenanceWindowProps | Properties for defining a |
ICfnMaintenanceWindowTargetProps | Properties for defining a |
ICfnMaintenanceWindowTaskProps | Properties for defining a |
ICfnParameterProps | Properties for defining a |
ICfnPatchBaselineProps | Properties for defining a |
ICfnResourceDataSyncProps | Properties for defining a |
ICfnResourcePolicyProps | Properties for defining a |
ICommonStringParameterAttributes | Common attributes for string parameters. |
IParameter | An SSM Parameter reference. |
IParameterOptions | Properties needed to create a new SSM Parameter. |
ISecureStringParameterAttributes | Attributes for secure string parameters. |
IStringListParameter | A StringList SSM Parameter. |
IStringListParameterProps | Properties needed to create a StringList SSM Parameter. |
IStringParameter | A String SSM Parameter. |
IStringParameterAttributes | Attributes for parameters of various types of string. |
IStringParameterProps | Properties needed to create a String SSM parameter. |