Skip to content
v2.277.0

StringParameterProps Struct ​

Properties needed to create a String SSM parameter.

Example ​

ts
import * as lambda from 'aws-cdk-lib/aws-lambda';

const simpleParameter = new ssm.StringParameter(this, 'StringParameter', {
  // the parameter name doesn't contain any '/'
  parameterName: 'parameter',
  stringValue: 'SOME_VALUE',
  simpleName: true, // set `simpleName` to true
});

declare const func: lambda.IFunction;
const nonSimpleParameter = new ssm.StringParameter(this, 'StringParameter', {
  // the parameter name contains '/'
  parameterName: `/${func.functionName}/my/app/param`,
  stringValue: 'SOME_VALUE',
  simpleName: false, // set `simpleName` to false
});
python
import aws_cdk.aws_lambda as lambda_

# func: lambda.IFunction


simple_parameter = ssm.StringParameter(self, "StringParameter",
    # the parameter name doesn't contain any '/'
    parameter_name="parameter",
    string_value="SOME_VALUE",
    simple_name=True
)
non_simple_parameter = ssm.StringParameter(self, "StringParameter",
    # the parameter name contains '/'
    parameter_name=f"/{func.functionName}/my/app/param",
    string_value="SOME_VALUE",
    simple_name=False
)
java
import software.amazon.awscdk.services.lambda.*;

IFunction func;


StringParameter simpleParameter = StringParameter.Builder.create(this, "StringParameter")
        // the parameter name doesn't contain any '/'
        .parameterName("parameter")
        .stringValue("SOME_VALUE")
        .simpleName(true)
        .build();
StringParameter nonSimpleParameter = StringParameter.Builder.create(this, "StringParameter")
        // the parameter name contains '/'
        .parameterName(String.format("/%s/my/app/param", func.getFunctionName()))
        .stringValue("SOME_VALUE")
        .simpleName(false)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;

IFunction func;


var simpleParameter = new StringParameter(this, "StringParameter", new StringParameterProps {
    // the parameter name doesn't contain any '/'
    ParameterName = "parameter",
    StringValue = "SOME_VALUE",
    SimpleName = true
});
var nonSimpleParameter = new StringParameter(this, "StringParameter", new StringParameterProps {
    // the parameter name contains '/'
    ParameterName = $"/{func.functionName}/my/app/param",
    StringValue = "SOME_VALUE",
    SimpleName = false
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"

var func IFunction


simpleParameter := ssm.NewStringParameter(this, jsii.String("StringParameter"), &StringParameterProps{
	// the parameter name doesn't contain any '/'
	ParameterName: jsii.String("parameter"),
	StringValue: jsii.String("SOME_VALUE"),
	SimpleName: jsii.Boolean(true),
})
nonSimpleParameter := ssm.NewStringParameter(this, jsii.String("StringParameter"), &StringParameterProps{
	// the parameter name contains '/'
	ParameterName: fmt.Sprintf("/%v/my/app/param", func.FunctionName),
	StringValue: jsii.String("SOME_VALUE"),
	SimpleName: jsii.Boolean(false),
})

Properties ​

allowedPatternoptionalstringallowed_patternoptionalstrallowedPatternoptionalStringAllowedPatternoptionalstringAllowedPatternoptional*string#
A regular expression used to validate the parameter value.

Default: no validation is performed

For example, for String types with values restricted to numbers, you can specify the following: ^\d+$

dataTypeoptionalParameterDataTypedata_typeoptionalParameterDataTypedataTypeoptionalParameterDataTypeDataTypeoptionalParameterDataTypeDataTypeoptionalParameterDataType= ParameterDataType.TEXT#
The data type of the parameter, such as `text` or `aws:ec2:image`.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= none#
Information about the parameter that you want to add to the system.
parameterNameoptionalstringparameter_nameoptionalstrparameterNameoptionalStringParameterNameoptionalstringParameterNameoptional*string#
The name of the parameter.

Default: a name will be generated by CloudFormation

simpleNameoptionalbooleansimple_nameoptionalboolsimpleNameoptionalBooleanSimpleNameoptionalboolSimpleNameoptional*bool#
Indicates whether the parameter name is a simple name.

Default: auto-detect based on parameterName

notes

A parameter name without any "/" is considered a simple name. If the parameter name includes "/", setting simpleName to true might cause unintended issues such as duplicate "/" in the resulting ARN.

This is required only if parameterName is a token, which means we are unable to detect if the name is simple or "path-like" for the purpose of rendering SSM parameter ARNs.

If parameterName is not specified, simpleName must be true (or undefined) since the name generated by AWS CloudFormation is always a simple name.

stringValuestringstring_valuestrstringValueStringStringValuestringStringValue*stringrequired#
The value of the parameter.

It may not reference another parameter and {{}} cannot be used in the value.

tieroptionalParameterTiertieroptionalParameterTiertieroptionalParameterTierTieroptionalParameterTierTieroptionalParameterTier= undefined#
The tier of the string parameter.
typeoptionalParameterTypetypeoptionalParameterTypetypeoptionalParameterTypeTypeoptionalParameterTypeTypeoptionalParameterType= ParameterType.STRINGdeprecated#
- type will always be 'String'