CfnParameter
- class aws_cdk.CfnParameter(scope, id, *, allowed_pattern=None, allowed_values=None, constraint_description=None, default=None, description=None, max_length=None, max_value=None, min_length=None, min_value=None, no_echo=None, type=None)
Bases:
CfnElement
A CloudFormation parameter.
Use the optional Parameters section to customize your templates. Parameters enable you to input custom values to your template each time you create or update a stack.
- ExampleMetadata:
infused
Example:
my_topic = sns.Topic(self, "MyTopic") url = CfnParameter(self, "url-param") my_topic.add_subscription(subscriptions.UrlSubscription(url.value_as_string))
Creates a parameter construct.
Note that the name (logical ID) of the parameter will derive from it’s
coname
and location within the stack. Therefore, it is recommended that parameters are defined at the stack level.- Parameters:
scope (
Construct
) – The parent construct.id (
str
) –allowed_pattern (
Optional
[str
]) – A regular expression that represents the patterns to allow for String types. Default: - No constraints on patterns allowed for parameter.allowed_values (
Optional
[Sequence
[str
]]) – An array containing the list of values allowed for the parameter. Default: - No constraints on values allowed for parameter.constraint_description (
Optional
[str
]) – A string that explains a constraint when the constraint is violated. For example, without a constraint description, a parameter that has an allowed pattern of [A-Za-z0-9]+ displays the following error message when the user specifies an invalid value: Default: - No description with customized error message when user specifies invalid values.default (
Any
) – A value of the appropriate type for the template to use if no value is specified when a stack is created. If you define constraints for the parameter, you must specify a value that adheres to those constraints. Default: - No default value for parameter.description (
Optional
[str
]) – A string of up to 4000 characters that describes the parameter. Default: - No description for the parameter.max_length (
Union
[int
,float
,None
]) – An integer value that determines the largest number of characters you want to allow for String types. Default: - None.max_value (
Union
[int
,float
,None
]) – A numeric value that determines the largest numeric value you want to allow for Number types. Default: - None.min_length (
Union
[int
,float
,None
]) – An integer value that determines the smallest number of characters you want to allow for String types. Default: - None.min_value (
Union
[int
,float
,None
]) – A numeric value that determines the smallest numeric value you want to allow for Number types. Default: - None.no_echo (
Optional
[bool
]) – Whether to mask the parameter value when anyone makes a call that describes the stack. If you set the value totrue
, the parameter value is masked with asterisks (*****
). Default: - Parameter values are not masked.type (
Optional
[str
]) – The data type for the parameter (DataType). Default: String
Methods
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- resolve(_context)
- Parameters:
_context (
IResolveContext
) –- Return type:
Any
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- allowed_pattern
A regular expression that represents the patterns to allow for String types.
- Default:
No constraints on patterns allowed for parameter.
- allowed_values
An array containing the list of values allowed for the parameter.
- Default:
No constraints on values allowed for parameter.
- constraint_description
A string that explains a constraint when the constraint is violated.
For example, without a constraint description, a parameter that has an allowed pattern of [A-Za-z0-9]+ displays the following error message when the user specifies an invalid value:
- Default:
No description with customized error message when user specifies invalid values.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- default
A value of the appropriate type for the template to use if no value is specified when a stack is created.
If you define constraints for the parameter, you must specify a value that adheres to those constraints.
- Default:
No default value for parameter.
- description
A string of up to 4000 characters that describes the parameter.
- Default:
No description for the parameter.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- max_length
An integer value that determines the largest number of characters you want to allow for String types.
- Default:
None.
- max_value
A numeric value that determines the largest numeric value you want to allow for Number types.
- Default:
None.
- min_length
An integer value that determines the smallest number of characters you want to allow for String types.
- Default:
None.
- min_value
A numeric value that determines the smallest numeric value you want to allow for Number types.
- Default:
None.
- no_echo
Indicates if this parameter is configured with “NoEcho” enabled.
- node
The tree node.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- type
The data type for the parameter (DataType).
- Default:
String
- value
The parameter value as a Token.
- value_as_list
The parameter value, if it represents a string list.
- value_as_number
The parameter value, if it represents a number.
- value_as_string
The parameter value, if it represents a string.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- 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
.