StringParameter

class aws_cdk.aws_ssm.StringParameter(scope, id, *, string_value, type=None, allowed_pattern=None, description=None, parameter_name=None, simple_name=None, tier=None)

Bases: aws_cdk.core.Resource

Creates a new String SSM Parameter.

resource: :resource:: AWS::SSM::Parameter

__init__(scope, id, *, string_value, type=None, allowed_pattern=None, description=None, parameter_name=None, simple_name=None, tier=None)
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.

  • type (Optional[ParameterType]) – The type of the string parameter. Default: ParameterType.STRING

  • allowed_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 performed

  • description (Optional[str]) – Information about the parameter that you want to add to the system. Default: none

  • parameter_name (Optional[str]) – The name of the parameter. Default: - a name will be generated by CloudFormation

  • simple_name (Optional[bool]) – Indicates of the parameter name is a simple name (i.e. does not include “/” separators). This is only 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

  • tier (Optional[ParameterTier]) – The tier of the string parameter. Default: - undefined

Return type

None

Methods

grant_read(grantee)

Grants read (DescribeParameter, GetParameter, GetParameterHistory) permissions on the SSM Parameter.

Parameters

grantee (IGrantable) –

Return type

Grant

grant_write(grantee)

Grants write (PutParameter) permissions on the SSM Parameter.

Parameters

grantee (IGrantable) –

Return type

Grant

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

Return type

Optional[IKey]

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.

Return type

ResourceEnvironment

node

The construct tree node associated with this construct.

Return type

ConstructNode

parameter_arn

The ARN of the SSM Parameter resource.

Return type

str

parameter_name

The name of the SSM Parameter resource.

Return type

str

parameter_type

The type of the SSM Parameter resource.

Return type

str

stack

The stack in which this resource is defined.

Return type

Stack

string_value

The parameter value.

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

Return type

str

Static Methods

classmethod from_secure_string_parameter_attributes(scope, id, *, version, encryption_key=None, parameter_name, simple_name=None)

Imports a secure string parameter from the SSM parameter store.

Parameters
  • scope (Construct) –

  • id (str) –

  • version (Union[int, float]) – The version number of the value you wish to retrieve. This is required for secure strings.

  • encryption_key (Optional[IKey]) – The encryption key that is used to encrypt this parameter. Default: - default master key

  • 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 of the parameter name is a simple name (i.e. does not include “/” separators). This is only 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

Return type

IStringParameter

classmethod from_string_parameter_attributes(scope, id, *, type=None, version=None, parameter_name, simple_name=None)

Imports an external string parameter with name and optional version.

Parameters
  • scope (Construct) –

  • id (str) –

  • type (Optional[ParameterType]) – The type of the string parameter. Default: ParameterType.STRING

  • version (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 of the parameter name is a simple name (i.e. does not include “/” separators). This is only 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

Return type

IStringParameter

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

IStringParameter

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool

classmethod value_for_secure_string_parameter(scope, parameter_name, version)

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).

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)

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).

Return type

str

classmethod value_from_lookup(scope, parameter_name)

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.

Parameters
  • scope (Construct) –

  • parameter_name (str) –

Return type

str