class StringParameter (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.SSM.StringParameter |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsssm#StringParameter |
![]() | software.amazon.awscdk.services.ssm.StringParameter |
![]() | aws_cdk.aws_ssm.StringParameter |
![]() | aws-cdk-lib » aws_ssm » StringParameter |
Implements
IConstruct
, IDependable
, IResource
, IString
, IParameter
Creates a new String SSM Parameter.
Example
const ssmParameter = new ssm.StringParameter(this, 'mySsmParameter', {
parameterName: 'mySsmParameter',
stringValue: 'mySsmParameterValue',
});
Initializer
new StringParameter(scope: Construct, id: string, props: StringParameterProps)
Parameters
- scope
Construct
- id
string
- props
String
Parameter Props
Construct Props
Name | Type | Description |
---|---|---|
string | string | The value of the parameter. |
allowed | string | A regular expression used to validate the parameter value. |
data | Parameter | The data type of the parameter, such as text or aws:ec2:image . |
description? | string | Information about the parameter that you want to add to the system. |
parameter | string | The name of the parameter. |
simple | boolean | Indicates whether the parameter name is a simple name. |
tier? | Parameter | The tier of the string parameter. |
type? | Parameter | The type of the string parameter. |
stringValue
Type:
string
The value of the parameter.
It may not reference another parameter and {{}}
cannot be used in the value.
allowedPattern?
Type:
string
(optional, default: 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+$
dataType?
Type:
Parameter
(optional, default: ParameterDataType.TEXT)
The data type of the parameter, such as text
or aws:ec2:image
.
description?
Type:
string
(optional, default: none)
Information about the parameter that you want to add to the system.
parameterName?
Type:
string
(optional, default: a name will be generated by CloudFormation)
The name of the parameter.
simpleName?
Type:
boolean
(optional, default: auto-detect based on parameterName
)
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 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.
tier?
Type:
Parameter
(optional, default: undefined)
The tier of the string parameter.
type?
⚠️ Deprecated: - type will always be 'String'
Type:
Parameter
(optional, default: ParameterType.STRING)
The type of the string parameter.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
parameter | string | The ARN of the SSM Parameter resource. |
parameter | string | The name of the SSM Parameter resource. |
parameter | string | The type of the SSM Parameter resource. |
stack | Stack | The stack in which this resource is defined. |
string | string | The parameter value. |
encryption | IKey | The encryption key that is used to encrypt this parameter. |
env
Type:
Resource
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
Type:
Node
The tree node.
parameterArn
Type:
string
The ARN of the SSM Parameter resource.
parameterName
Type:
string
The name of the SSM Parameter resource.
parameterType
Type:
string
The type of the SSM Parameter resource.
stack
Type:
Stack
The stack in which this resource is defined.
stringValue
Type:
string
The parameter value.
Value must not nest another parameter. Do not use {{}} in the value.
encryptionKey?
Type:
IKey
(optional, default: default master key)
The encryption key that is used to encrypt this parameter.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
grant | Grants read (DescribeParameter, GetParameters, GetParameter, GetParameterHistory) permissions on the SSM Parameter. |
grant | Grants write (PutParameter) permissions on the SSM Parameter. |
to | Returns a string representation of this construct. |
static from | Imports a secure string parameter from the SSM parameter store. |
static from | Imports an external string parameter by ARN. |
static from | Imports an external string parameter with name and optional version. |
static from | Imports an external string parameter by name. |
static value | Returns a token that will resolve (during deployment). |
static value | Returns a token that will resolve (during deployment) to the string value of an SSM string parameter. |
static value | Returns a token that will resolve (during deployment) to the string value of an SSM string parameter. |
static value | Returns a token that will resolve (during deployment) to the string value of an SSM string parameter. |
static value | Reads the value of an SSM parameter during synthesis through an environmental context provider. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grants read (DescribeParameter, GetParameters, GetParameter, GetParameterHistory) permissions on the SSM Parameter.
grantWrite(grantee)
public grantWrite(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grants write (PutParameter) permissions on the SSM Parameter.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromSecureStringParameterAttributes(scope, id, attrs)
public static fromSecureStringParameterAttributes(scope: Construct, id: string, attrs: SecureStringParameterAttributes): IStringParameter
Parameters
- scope
Construct
- id
string
- attrs
Secure
String Parameter Attributes
Returns
Imports a secure string parameter from the SSM parameter store.
static fromStringParameterArn(scope, id, stringParameterArn)
public static fromStringParameterArn(scope: Construct, id: string, stringParameterArn: string): IStringParameter
Parameters
- scope
Construct
- id
string
- stringParameterArn
string
Returns
Imports an external string parameter by ARN.
static fromStringParameterAttributes(scope, id, attrs)
public static fromStringParameterAttributes(scope: Construct, id: string, attrs: StringParameterAttributes): IStringParameter
Parameters
- scope
Construct
- id
string
- attrs
String
Parameter Attributes
Returns
Imports an external string parameter with name and optional version.
static fromStringParameterName(scope, id, stringParameterName)
public static fromStringParameterName(scope: Construct, id: string, stringParameterName: string): IStringParameter
Parameters
- scope
Construct
- id
string
- stringParameterName
string
Returns
Imports an external string parameter by name.
static valueForSecureStringParameter(scope, parameterName, version)
public static valueForSecureStringParameter(scope: Construct, parameterName: string, version: number): string
⚠️ Deprecated: 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.
Parameters
- scope
Construct
— Some scope within a stack. - parameterName
string
— The name of the SSM parameter. - version
number
— The parameter version (required for secure strings).
Returns
string
Returns a token that will resolve (during deployment).
static valueForStringParameter(scope, parameterName, version?)
public static valueForStringParameter(scope: Construct, parameterName: string, version?: number): string
Parameters
- scope
Construct
— Some scope within a stack. - parameterName
string
— The name of the SSM parameter. - version
number
— The parameter version (recommended in order to ensure that the value won't change during deployment).
Returns
string
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
static valueForTypedStringParameter(scope, parameterName, type?, version?)
public static valueForTypedStringParameter(scope: Construct, parameterName: string, type?: ParameterType, version?: number): string
⚠️ Deprecated: - use valueForTypedStringParameterV2 instead
Parameters
- scope
Construct
— Some scope within a stack. - parameterName
string
— The name of the SSM parameter. - type
Parameter
— The type of the SSM parameter.Type - version
number
— The parameter version (recommended in order to ensure that the value won't change during deployment).
Returns
string
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
static valueForTypedStringParameterV2(scope, parameterName, type?, version?)
public static valueForTypedStringParameterV2(scope: Construct, parameterName: string, type?: ParameterValueType, version?: number): string
Parameters
- scope
Construct
— Some scope within a stack. - parameterName
string
— The name of the SSM parameter. - type
Parameter
— The type of the SSM parameter.Value Type - version
number
— The parameter version (recommended in order to ensure that the value won't change during deployment).
Returns
string
Returns a token that will resolve (during deployment) to the string value of an SSM string parameter.
static valueFromLookup(scope, parameterName, defaultValue?)
public static valueFromLookup(scope: Construct, parameterName: string, defaultValue?: string): string
Parameters
- scope
Construct
- parameterName
string
- defaultValue
string
Returns
string
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.