StringParameter
- class aws_cdk.aws_ssm.StringParameter(scope, id, *, string_value, data_type=None, type=None, allowed_pattern=None, description=None, parameter_name=None, simple_name=None, tier=None)
Bases:
Resource
Creates a new String SSM Parameter.
- Resource:
AWS::SSM::Parameter
Example:
ssm_parameter = ssm.StringParameter(self, "mySsmParameter", parameter_name="mySsmParameter", string_value="mySsmParameterValue" )
- Parameters:
scope (
Construct
) –id (
str
) –string_value (
str
) – The value of the parameter. It may not reference another parameter and{{}}
cannot be used in the value.data_type (
Optional
[ParameterDataType
]) – The data type of the parameter, such astext
oraws:ec2:image
. Default: ParameterDataType.TEXTtype (
Optional
[ParameterType
]) – (deprecated) The type of the string parameter. Default: ParameterType.STRINGallowed_pattern (
Optional
[str
]) – 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+$
Default: no validation is performeddescription (
Optional
[str
]) – Information about the parameter that you want to add to the system. Default: noneparameter_name (
Optional
[str
]) – The name of the parameter. Default: - a name will be generated by CloudFormationsimple_name (
Optional
[bool
]) – Indicates whether the parameter name is a simple name. 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 ifparameterName
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. IfparameterName
is not specified,simpleName
must betrue
(or undefined) since the name generated by AWS CloudFormation is always a simple name. Default: - auto-detect based onparameterName
tier (
Optional
[ParameterTier
]) – The tier of the string parameter. Default: - undefined
Methods
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
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
).- Parameters:
policy (
RemovalPolicy
) –- Return type:
None
- grant_read(grantee)
Grants read (DescribeParameter, GetParameters, GetParameter, GetParameterHistory) permissions on the SSM Parameter.
- Parameters:
grantee (
IGrantable
) –- Return type:
- grant_write(grantee)
Grants write (PutParameter) permissions on the SSM Parameter.
- Parameters:
grantee (
IGrantable
) –- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- encryption_key
The encryption key that is used to encrypt this parameter.
- Default:
default master key
- env
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- node
The tree node.
- parameter_arn
The ARN of the SSM Parameter resource.
- parameter_name
The name of the SSM Parameter resource.
- parameter_type
The type of the SSM Parameter resource.
- stack
The stack in which this resource is defined.
- string_value
The parameter value.
Value must not nest another parameter. Do not use {{}} in the value.
Static Methods
- classmethod from_secure_string_parameter_attributes(scope, id, *, encryption_key=None, version=None, parameter_name, simple_name=None)
Imports a secure string parameter from the SSM parameter store.
- Parameters:
scope (
Construct
) –id (
str
) –encryption_key (
Optional
[IKey
]) – The encryption key that is used to encrypt this parameter. Default: - default master keyversion (
Union
[int
,float
,None
]) – The version number of the value you wish to retrieve. Default: - AWS CloudFormation uses the latest version of the parameterparameter_name (
str
) – 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).simple_name (
Optional
[bool
]) – Indicates whether the parameter name is a simple name. 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 ifparameterName
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. IfparameterName
is not specified,simpleName
must betrue
(or undefined) since the name generated by AWS CloudFormation is always a simple name. Default: - auto-detect based onparameterName
- Return type:
- classmethod from_string_parameter_arn(scope, id, string_parameter_arn)
Imports an external string parameter by ARN.
- Parameters:
scope (
Construct
) –id (
str
) –string_parameter_arn (
str
) –
- Return type:
- classmethod from_string_parameter_attributes(scope, id, *, force_dynamic_reference=None, type=None, value_type=None, version=None, parameter_name, simple_name=None)
Imports an external string parameter with name and optional version.
- Parameters:
scope (
Construct
) –id (
str
) –force_dynamic_reference (
Optional
[bool
]) – 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. Default: falsetype (
Optional
[ParameterType
]) – (deprecated) The type of the string parameter. Default: ParameterType.STRINGvalue_type (
Optional
[ParameterValueType
]) – The type of the string parameter value. 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 Default: ParameterValueType.STRINGversion (
Union
[int
,float
,None
]) – The version number of the value you wish to retrieve. Default: The latest version will be retrieved.parameter_name (
str
) – 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).simple_name (
Optional
[bool
]) – Indicates whether the parameter name is a simple name. 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 ifparameterName
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. IfparameterName
is not specified,simpleName
must betrue
(or undefined) since the name generated by AWS CloudFormation is always a simple name. Default: - auto-detect based onparameterName
- Return type:
- classmethod from_string_parameter_name(scope, id, string_parameter_name)
Imports an external string parameter by name.
- Parameters:
scope (
Construct
) –id (
str
) –string_parameter_name (
str
) –
- Return type:
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
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 classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
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 theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod value_for_secure_string_parameter(scope, parameter_name, version)
(deprecated) Returns a token that will resolve (during deployment).
- Parameters:
scope (
Construct
) – Some scope within a stack.parameter_name (
str
) – The name of the SSM parameter.version (
Union
[int
,float
]) – The parameter version (required for secure strings).
- Deprecated:
Use
SecretValue.ssmSecure()
instead, it will correctly type the imported value as aSecretValue
and allow importing without version.SecretValue
lives in the coreaws-cdk-lib
module.- Stability:
deprecated
- Return type:
str
- classmethod value_for_string_parameter(scope, parameter_name, version=None)
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
- Parameters:
scope (
Construct
) – Some scope within a stack.parameter_name (
str
) – The name of the SSM parameter.version (
Union
[int
,float
,None
]) – The parameter version (recommended in order to ensure that the value won’t change during deployment).
- Return type:
str
- classmethod value_for_typed_string_parameter(scope, parameter_name, type=None, version=None)
(deprecated) Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
- Parameters:
scope (
Construct
) – Some scope within a stack.parameter_name (
str
) – The name of the SSM parameter.type (
Optional
[ParameterType
]) – The type of the SSM parameter.version (
Union
[int
,float
,None
]) – The parameter version (recommended in order to ensure that the value won’t change during deployment).
- Deprecated:
use valueForTypedStringParameterV2 instead
- Stability:
deprecated
- Return type:
str
- classmethod value_for_typed_string_parameter_v2(scope, parameter_name, type=None, version=None)
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
- Parameters:
scope (
Construct
) – Some scope within a stack.parameter_name (
str
) – The name of the SSM parameter.type (
Optional
[ParameterValueType
]) – The type of the SSM parameter.version (
Union
[int
,float
,None
]) – The parameter version (recommended in order to ensure that the value won’t change during deployment).
- Return type:
str
- classmethod value_from_lookup(scope, parameter_name, default_value=None)
Reads the value of an SSM parameter during synthesis through an environmental context provider.
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.
- Parameters:
scope (
Construct
) –parameter_name (
str
) –default_value (
Optional
[str
]) –
- Return type:
str