Skip to content
v2.277.0

StringParameterAttributes Struct ​

Attributes for parameters of various types of string.

Example ​

ts
const parameterVersion = Token.asNumber({ Ref: 'MyParameter' });

// Retrieve the latest value of the non-secret parameter
// with name "/My/String/Parameter".
const stringValue = ssm.StringParameter.fromStringParameterAttributes(this, 'MyValue', {
  parameterName: '/My/Public/Parameter',
  // 'version' can be specified but is optional.
}).stringValue;
const stringValueVersionFromToken = ssm.StringParameter.fromStringParameterAttributes(this, 'MyValueVersionFromToken', {
  parameterName: '/My/Public/Parameter',
  // parameter version from token
  version: parameterVersion,
}).stringValue;

// Retrieve a specific version of the secret (SecureString) parameter.
// 'version' is always required.
const secretValue = ssm.StringParameter.fromSecureStringParameterAttributes(this, 'MySecureValue', {
  parameterName: '/My/Secret/Parameter',
  version: 5,
});
const secretValueVersionFromToken = ssm.StringParameter.fromSecureStringParameterAttributes(this, 'MySecureValueVersionFromToken', {
  parameterName: '/My/Secret/Parameter',
  // parameter version from token
  version: parameterVersion,
});
python
parameter_version = Token.as_number({"Ref": "MyParameter"})

# Retrieve the latest value of the non-secret parameter
# with name "/My/String/Parameter".
string_value = ssm.StringParameter.from_string_parameter_attributes(self, "MyValue",
    parameter_name="/My/Public/Parameter"
).string_value
string_value_version_from_token = ssm.StringParameter.from_string_parameter_attributes(self, "MyValueVersionFromToken",
    parameter_name="/My/Public/Parameter",
    # parameter version from token
    version=parameter_version
).string_value

# Retrieve a specific version of the secret (SecureString) parameter.
# 'version' is always required.
secret_value = ssm.StringParameter.from_secure_string_parameter_attributes(self, "MySecureValue",
    parameter_name="/My/Secret/Parameter",
    version=5
)
secret_value_version_from_token = ssm.StringParameter.from_secure_string_parameter_attributes(self, "MySecureValueVersionFromToken",
    parameter_name="/My/Secret/Parameter",
    # parameter version from token
    version=parameter_version
)
java
Number parameterVersion = Token.asNumber(Map.of("Ref", "MyParameter"));

// 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());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var parameterVersion = Token.AsNumber(new Dictionary<string, string> { { "Ref", "MyParameter" } });

// 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
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
parameterVersion := awscdk.Token_AsNumber(map[string]*string{
	"Ref": jsii.String("MyParameter"),
})

// Retrieve the latest value of the non-secret parameter
// with name "/My/String/Parameter".
stringValue := ssm.StringParameter_FromStringParameterAttributes(this, jsii.String("MyValue"), &StringParameterAttributes{
	ParameterName: jsii.String("/My/Public/Parameter"),
}).StringValue
stringValueVersionFromToken := ssm.StringParameter_FromStringParameterAttributes(this, jsii.String("MyValueVersionFromToken"), &StringParameterAttributes{
	ParameterName: jsii.String("/My/Public/Parameter"),
	// parameter version from token
	Version: parameterVersion,
}).StringValue

// Retrieve a specific version of the secret (SecureString) parameter.
// 'version' is always required.
secretValue := ssm.StringParameter_FromSecureStringParameterAttributes(this, jsii.String("MySecureValue"), &SecureStringParameterAttributes{
	ParameterName: jsii.String("/My/Secret/Parameter"),
	Version: jsii.Number(5),
})
secretValueVersionFromToken := ssm.StringParameter_FromSecureStringParameterAttributes(this, jsii.String("MySecureValueVersionFromToken"), &SecureStringParameterAttributes{
	ParameterName: jsii.String("/My/Secret/Parameter"),
	// parameter version from token
	Version: parameterVersion,
})

Properties ​

forceDynamicReferenceoptionalbooleanforce_dynamic_referenceoptionalboolforceDynamicReferenceoptionalBooleanForceDynamicReferenceoptionalboolForceDynamicReferenceoptional*bool= false#
Use a dynamic reference as the representation in CloudFormation template level.

By default, CDK tries to deduce an appropriate representation based on the parameter value (a CfnParameter or a dynamic reference). Use this flag to override the representation when it does not work.

parameterNamestringparameter_namestrparameterNameStringParameterNamestringParameterName*stringrequired#
The name of the parameter store value.

This value can be a token or a concrete string. If it is a concrete string and includes "/" it must also be prefixed with a "/" (fully-qualified).

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.

typeoptionalParameterTypetypeoptionalParameterTypetypeoptionalParameterTypeTypeoptionalParameterTypeTypeoptionalParameterType= ParameterType.STRINGdeprecated#
- use valueType instead
valueTypeoptionalParameterValueTypevalue_typeoptionalParameterValueTypevalueTypeoptionalParameterValueTypeValueTypeoptionalParameterValueTypeValueTypeoptionalParameterValueType= ParameterValueType.STRING#
The type of the string parameter value.
notes

Using specific types can be helpful in catching invalid values at the start of creating or updating a stack. CloudFormation validates the values against existing values in the account.

Note - if you want to allow values from different AWS accounts, use ParameterValueType.STRING

versionoptionalnumberversionoptionalint | floatversionoptionalNumberVersionoptionaldoubleVersionoptional*float64#
The version number of the value you wish to retrieve.

Default: The latest version will be retrieved.