Skip to content
v2.274.0

StringParameter L2 construct ​

Creates a new String SSM Parameter.

Example ​

ts
const ssmParameter = new ssm.StringParameter(this, 'mySsmParameter', {
   parameterName: 'mySsmParameter',
   stringValue: 'mySsmParameterValue',
});
python
ssm_parameter = ssm.StringParameter(self, "mySsmParameter",
    parameter_name="mySsmParameter",
    string_value="mySsmParameterValue"
)
java
StringParameter ssmParameter = StringParameter.Builder.create(this, "mySsmParameter")
        .parameterName("mySsmParameter")
        .stringValue("mySsmParameterValue")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var ssmParameter = new StringParameter(this, "mySsmParameter", new StringParameterProps {
    ParameterName = "mySsmParameter",
    StringValue = "mySsmParameterValue"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
ssmParameter := ssm.NewStringParameter(this, jsii.String("mySsmParameter"), &StringParameterProps{
	ParameterName: jsii.String("mySsmParameter"),
	StringValue: jsii.String("mySsmParameterValue"),
})

Initializer ​

ts
new StringParameter(scope: Construct, id: string, props: StringParameterProps)
python
StringParameter(scope: Construct, id: str, props: StringParameterProps)
java
new StringParameter(Construct scope, String id, StringParameterProps props)
csharp
new StringParameter(Construct scope, string id, StringParameterProps props)
go
NewStringParameter(Scope Construct, Id *string, Props StringParameterProps)

Construct Props ​

allowedPatternstringallowed_patternstrallowedPatternStringAllowedPatternstringAllowedPattern*string= no validation is performed#
A regular expression used to validate the parameter value.

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

dataTypeParameterDataTypedata_typeParameterDataTypedataTypeParameterDataTypeDataTypeParameterDataTypeDataTypeParameterDataType= ParameterDataType.TEXT#
The data type of the parameter, such as `text` or `aws:ec2:image`.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= none#
Information about the parameter that you want to add to the system.
parameterNamestringparameter_namestrparameterNameStringParameterNamestringParameterName*string= a name will be generated by Clou…#
The name of the parameter.
default

Default: a name will be generated by CloudFormation

simpleNamebooleansimple_nameboolsimpleNameBooleanSimpleNameboolSimpleName*bool= auto-detect based on `parameterN…#
Indicates whether the parameter name is a simple name.
notes · default

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.

Default: auto-detect based on parameterName

stringValuestringstring_valuestrstringValueStringStringValuestringStringValue*stringrequired#
The value of the parameter.

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

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

Properties ​

encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey= default master key#
The encryption key that is used to encrypt this parameter.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
parameterArnstringparameter_arnstrparameterArnStringParameterArnstringParameterArn*stringrequired#
The ARN of the SSM Parameter resource.
parameterNamestringparameter_namestrparameterNameStringParameterNamestringParameterName*stringrequired#
The name of the SSM Parameter resource.
parameterRefParameterReferenceparameter_refParameterReferenceparameterRefParameterReferenceParameterRefParameterReferenceParameterRefParameterReferencerequired#
A reference to a Parameter resource.
parameterTypestringparameter_typestrparameterTypeStringParameterTypestringParameterType*stringrequired#
The type of the SSM Parameter resource.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
stringValuestringstring_valuestrstringValueStringStringValuestringStringValue*stringrequired#
The parameter value.

Value must not nest another parameter. Do not use {{}} in the value.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromSecureStringParameterAttributes(scope: Construct, id: string, attrs: SecureStringParameterAttributes): IStringParameter@staticmethod def from_secure_string_parameter_attributes(scope: Construct, id: str, attrs: SecureStringParameterAttributes) -> IStringParameterpublic static IStringParameter fromSecureStringParameterAttributes(Construct scope, String id, SecureStringParameterAttributes attrs)public static IStringParameter FromSecureStringParameterAttributes(Construct scope, string id, SecureStringParameterAttributes attrs)func FromSecureStringParameterAttributes(Scope Construct, Id *string, Attrs SecureStringParameterAttributes) IStringParameterstatic#
Imports a secure string parameter from the SSM parameter store.
fromStringParameterArn(scope: Construct, id: string, stringParameterArn: string): IStringParameter@staticmethod def from_string_parameter_arn(scope: Construct, id: str, string_parameter_arn: str) -> IStringParameterpublic static IStringParameter fromStringParameterArn(Construct scope, String id, String stringParameterArn)public static IStringParameter FromStringParameterArn(Construct scope, string id, string stringParameterArn)func FromStringParameterArn(Scope Construct, Id *string, StringParameterArn *string) IStringParameterstatic#
Imports an external string parameter by ARN.
fromStringParameterAttributes(scope: Construct, id: string, attrs: StringParameterAttributes): IStringParameter@staticmethod def from_string_parameter_attributes(scope: Construct, id: str, attrs: StringParameterAttributes) -> IStringParameterpublic static IStringParameter fromStringParameterAttributes(Construct scope, String id, StringParameterAttributes attrs)public static IStringParameter FromStringParameterAttributes(Construct scope, string id, StringParameterAttributes attrs)func FromStringParameterAttributes(Scope Construct, Id *string, Attrs StringParameterAttributes) IStringParameterstatic#
Imports an external string parameter with name and optional version.
fromStringParameterName(scope: Construct, id: string, stringParameterName: string): IStringParameter@staticmethod def from_string_parameter_name(scope: Construct, id: str, string_parameter_name: str) -> IStringParameterpublic static IStringParameter fromStringParameterName(Construct scope, String id, String stringParameterName)public static IStringParameter FromStringParameterName(Construct scope, string id, string stringParameterName)func FromStringParameterName(Scope Construct, Id *string, StringParameterName *string) IStringParameterstatic#
Imports an external string parameter by name.
grantOnKey(grantee: IGrantable, ...actions: string[]): GrantOnKeyResultdef grant_on_key(self, grantee: IGrantable, actions: str) -> GrantOnKeyResultpublic GrantOnKeyResult grantOnKey(IGrantable grantee, String actions)public GrantOnKeyResult GrantOnKey(IGrantable grantee, string actions)func GrantOnKey(Grantee IGrantable, Actions *string) GrantOnKeyResult#
Gives permissions to a grantable entity to perform actions on the encryption key.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#
[disable-awslint:no-grants].
grantWrite(grantee: IGrantable): Grantdef grant_write(self, grantee: IGrantable) -> Grantpublic Grant grantWrite(IGrantable grantee)public Grant GrantWrite(IGrantable grantee)func GrantWrite(Grantee IGrantable) Grant#
[disable-awslint:no-grants].
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
valueForSecureStringParameter(scope: Construct, parameterName: string, version: number): string@staticmethod def value_for_secure_string_parameter(scope: Construct, parameter_name: str, version: int | float) -> strpublic static String valueForSecureStringParameter(Construct scope, String parameterName, Number version)public static string ValueForSecureStringParameter(Construct scope, string parameterName, double version)func ValueForSecureStringParameter(Scope Construct, ParameterName *string, Version *float64) *stringstaticdeprecated#
Use `SecretValue.ssmSecure()` instead, it will correctly type the imported value as a `SecretValue` and allow importing without version. `SecretValue` lives in the core `aws-cdk-lib` module.
3 parameters

Parameters

  • scopescopescopescopeScope — Some scope within a stack.
  • parameterNameparameter_nameparameterNameparameterNameParameterName — The name of the SSM parameter.
  • versionversionversionversionVersion — The parameter version (required for secure strings).
valueForStringParameter(scope: Construct, parameterName: string, version?: number): string@staticmethod def value_for_string_parameter(scope: Construct, parameter_name: str, version: typing.Optional[int | float] = None) -> strpublic static String valueForStringParameter(Construct scope, String parameterName, Number version)public static string ValueForStringParameter(Construct scope, string parameterName, double? version = null)func ValueForStringParameter(Scope Construct, ParameterName *string, Version *float64) *stringstatic#
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
3 parameters

Parameters

  • scopescopescopescopeScope — Some scope within a stack.
  • parameterNameparameter_nameparameterNameparameterNameParameterName — The name of the SSM parameter.
  • versionversionversionversionVersion — The parameter version (recommended in order to ensure that the value won't change during deployment).
valueForTypedStringParameter(scope: Construct, parameterName: string, type?: ParameterType, version?: number): string@staticmethod def value_for_typed_string_parameter(scope: Construct, parameter_name: str, type: typing.Optional[ParameterType] = None, version: typing.Optional[int | float] = None) -> strpublic static String valueForTypedStringParameter(Construct scope, String parameterName, ParameterType type, Number version)public static string ValueForTypedStringParameter(Construct scope, string parameterName, ParameterType? type = null, double? version = null)func ValueForTypedStringParameter(Scope Construct, ParameterName *string, Type ParameterType, Version *float64) *stringstaticdeprecated#
- use valueForTypedStringParameterV2 instead
4 parameters

Parameters

  • scopescopescopescopeScope — Some scope within a stack.
  • parameterNameparameter_nameparameterNameparameterNameParameterName — The name of the SSM parameter.
  • typetypetypetypeType — The type of the SSM parameter.
  • versionversionversionversionVersion — The parameter version (recommended in order to ensure that the value won't change during deployment).
valueForTypedStringParameterV2(scope: Construct, parameterName: string, type?: ParameterValueType, version?: number): string@staticmethod def value_for_typed_string_parameter_v2(scope: Construct, parameter_name: str, type: typing.Optional[ParameterValueType] = None, version: typing.Optional[int | float] = None) -> strpublic static String valueForTypedStringParameterV2(Construct scope, String parameterName, ParameterValueType type, Number version)public static string ValueForTypedStringParameterV2(Construct scope, string parameterName, ParameterValueType? type = null, double? version = null)func ValueForTypedStringParameterV2(Scope Construct, ParameterName *string, Type ParameterValueType, Version *float64) *stringstatic#
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
4 parameters

Parameters

  • scopescopescopescopeScope — Some scope within a stack.
  • parameterNameparameter_nameparameterNameparameterNameParameterName — The name of the SSM parameter.
  • typetypetypetypeType — The type of the SSM parameter.
  • versionversionversionversionVersion — The parameter version (recommended in order to ensure that the value won't change during deployment).
valueFromLookup(scope: Construct, parameterName: string, defaultValue?: string, options?: StringParameterLookupOptions): string@staticmethod def value_from_lookup(scope: Construct, parameter_name: str, default_value: typing.Optional[str] = None, options: typing.Optional[StringParameterLookupOptions] = None) -> strpublic static String valueFromLookup(Construct scope, String parameterName, String defaultValue, StringParameterLookupOptions options)public static string ValueFromLookup(Construct scope, string parameterName, string? defaultValue = null, StringParameterLookupOptions? options = null)func ValueFromLookup(Scope Construct, ParameterName *string, DefaultValue *string, Options StringParameterLookupOptions) *stringstatic#
Reads the value of an SSM parameter during synthesis through an environmental context provider.
notes

Requires that the stack this scope is defined in will have explicit account/region information. Otherwise, it will fail during synthesis.

If defaultValue is provided, it will be used as the dummyValue and the ContextProvider will be told NOT to raise an error on synthesis if the SSM Parameter is not found in the account at synth time.

with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.