Skip to content
v2.273.0

CfnParameter L1 construct ​

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.

Example ​

ts
const myTopic = new sns.Topic(this, 'MyTopic');
const url = new CfnParameter(this, 'url-param');

myTopic.addSubscription(new subscriptions.UrlSubscription(url.valueAsString));
python
my_topic = sns.Topic(self, "MyTopic")
url = CfnParameter(self, "url-param")

my_topic.add_subscription(subscriptions.UrlSubscription(url.value_as_string))
java
Topic myTopic = new Topic(this, "MyTopic");
CfnParameter url = new CfnParameter(this, "url-param");

myTopic.addSubscription(new UrlSubscription(url.getValueAsString()));
csharp
// Install: dotnet add package Amazon.CDK.Lib
var myTopic = new Topic(this, "MyTopic");
var url = new CfnParameter(this, "url-param");

myTopic.AddSubscription(new UrlSubscription(url.ValueAsString));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
myTopic := sns.NewTopic(this, jsii.String("MyTopic"))
url := awscdk.NewCfnParameter(this, jsii.String("url-param"))

myTopic.AddSubscription(subscriptions.NewUrlSubscription(url.valueAsString))

Initializer ​

ts
new CfnParameter(scope: Construct, id: string, props?: CfnParameterProps)
python
CfnParameter(scope: Construct, id: str, props: typing.Optional[CfnParameterProps] = None)
java
new CfnParameter(Construct scope, String id, CfnParameterProps props)
csharp
new CfnParameter(Construct scope, string id, CfnParameterProps? props = null)
go
NewCfnParameter(Scope Construct, Id *string, Props CfnParameterProps)

Construct Props ​

allowedPatternstringallowed_patternstrallowedPatternStringAllowedPatternstringAllowedPattern*string= No constraints on patterns allow…#
A regular expression that represents the patterns to allow for String types.
default

Default: No constraints on patterns allowed for parameter.

allowedValuesstring[]allowed_valuestyping.List[str]allowedValuesList<String>AllowedValuesstring[]AllowedValues*[]*string= No constraints on values allowed…#
An array containing the list of values allowed for the parameter.
default

Default: No constraints on values allowed for parameter.

constraintDescriptionstringconstraint_descriptionstrconstraintDescriptionStringConstraintDescriptionstringConstraintDescription*string= No description with customized e…#
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

Default: No description with customized error message when user specifies invalid values.

defaultanydefaultAnydefaultObjectDefaultobjectDefaultinterface{}= No default value for parameter.#
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.

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= No description for the parameter…#
A string of up to 4000 characters that describes the parameter.
default

Default: No description for the parameter.

maxLengthnumbermax_lengthint | floatmaxLengthNumberMaxLengthdoubleMaxLength*float64= None.#
An integer value that determines the largest number of characters you want to allow for String types.
maxValuenumbermax_valueint | floatmaxValueNumberMaxValuedoubleMaxValue*float64= None.#
A numeric value that determines the largest numeric value you want to allow for Number types.
minLengthnumbermin_lengthint | floatminLengthNumberMinLengthdoubleMinLength*float64= None.#
An integer value that determines the smallest number of characters you want to allow for String types.
minValuenumbermin_valueint | floatminValueNumberMinValuedoubleMinValue*float64= None.#
A numeric value that determines the smallest numeric value you want to allow for Number types.
noEchobooleanno_echoboolnoEchoBooleanNoEchoboolNoEcho*bool= Parameter values are not masked.#
Whether to mask the parameter value when anyone makes a call that describes the stack.

If you set the value to true, the parameter value is masked with asterisks (*****).

typestringtypestrtypeStringTypestringType*string= String#
The data type for the parameter (DataType).

Properties ​

allowedPatternstringallowed_patternstrallowedPatternStringAllowedPatternstringAllowedPattern*string= No constraints on patterns allow…#
A regular expression that represents the patterns to allow for String types.
default

Default: No constraints on patterns allowed for parameter.

allowedValuesstring[]allowed_valuestyping.List[str]allowedValuesList<String>AllowedValuesstring[]AllowedValues*[]*string= No constraints on values allowed…#
An array containing the list of values allowed for the parameter.
default

Default: No constraints on values allowed for parameter.

constraintDescriptionstringconstraint_descriptionstrconstraintDescriptionStringConstraintDescriptionstringConstraintDescription*string= No description with customized e…#
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

Default: No description with customized error message when user specifies invalid values.

creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#
defaultanydefaultAnydefaultObjectDefaultobjectDefaultinterface{}= No default value for parameter.required#
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.

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= No description for the parameter…#
A string of up to 4000 characters that describes the parameter.
default

Default: No description for the parameter.

logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*stringrequired#
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).

maxLengthnumbermax_lengthint | floatmaxLengthNumberMaxLengthdoubleMaxLength*float64= None.#
An integer value that determines the largest number of characters you want to allow for String types.
maxValuenumbermax_valueint | floatmaxValueNumberMaxValuedoubleMaxValue*float64= None.#
A numeric value that determines the largest numeric value you want to allow for Number types.
minLengthnumbermin_lengthint | floatminLengthNumberMinLengthdoubleMinLength*float64= None.#
An integer value that determines the smallest number of characters you want to allow for String types.
minValuenumbermin_valueint | floatminValueNumberMinValuedoubleMinValue*float64= None.#
A numeric value that determines the smallest numeric value you want to allow for Number types.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
noEchobooleanno_echoboolnoEchoBooleanNoEchoboolNoEcho*boolrequired#
Indicates if this parameter is configured with "NoEcho" enabled.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

typestringtypestrtypeStringTypestringType*string= Stringrequired#
The data type for the parameter (DataType).
The parameter value as a Token.
valueAsListstring[]value_as_listtyping.List[str]valueAsListList<String>ValueAsListstring[]ValueAsList*[]*stringrequired#
The parameter value, if it represents a string list.
valueAsNumbernumbervalue_as_numberint | floatvalueAsNumberNumberValueAsNumberdoubleValueAsNumber*float64required#
The parameter value, if it represents a number.
valueAsStringstringvalue_as_stringstrvalueAsStringStringValueAsStringstringValueAsString*stringrequired#
The parameter value, if it represents a string.

Methods ​

isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#
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.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

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.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
resolve(_context: IResolveContext): anydef resolve(self, _context: IResolveContext) -> Anypublic Object resolve(IResolveContext _context)public object Resolve(IResolveContext _context)func Resolve(_context IResolveContext) interface{}#
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
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.