aws-cdk-lib.CfnParameter

class CfnParameter (construct)

LanguageType name
.NETAmazon.CDK.CfnParameter
Gogithub.com/aws/aws-cdk-go/awscdk/v2#CfnParameter
Javasoftware.amazon.awscdk.CfnParameter
Pythonaws_cdk.CfnParameter
TypeScript (source)aws-cdk-lib » CfnParameter

Implements IConstruct, IDependable

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

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

myTopic.addSubscription(new subscriptions.UrlSubscription(url.valueAsString));

Initializer

new CfnParameter(scope: Construct, id: string, props?: CfnParameterProps)

Parameters

  • scope Construct — The parent construct.
  • id string
  • props CfnParameterProps — The parameter properties.

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.

Construct Props

NameTypeDescription
allowedPattern?stringA regular expression that represents the patterns to allow for String types.
allowedValues?string[]An array containing the list of values allowed for the parameter.
constraintDescription?stringA string that explains a constraint when the constraint is violated.
default?anyA value of the appropriate type for the template to use if no value is specified when a stack is created.
description?stringA string of up to 4000 characters that describes the parameter.
maxLength?numberAn integer value that determines the largest number of characters you want to allow for String types.
maxValue?numberA numeric value that determines the largest numeric value you want to allow for Number types.
minLength?numberAn integer value that determines the smallest number of characters you want to allow for String types.
minValue?numberA numeric value that determines the smallest numeric value you want to allow for Number types.
noEcho?booleanWhether to mask the parameter value when anyone makes a call that describes the stack.
type?stringThe data type for the parameter (DataType).

allowedPattern?

Type: string (optional, default: No constraints on patterns allowed for parameter.)

A regular expression that represents the patterns to allow for String types.


allowedValues?

Type: string[] (optional, default: No constraints on values allowed for parameter.)

An array containing the list of values allowed for the parameter.


constraintDescription?

Type: string (optional, default: No description with customized error message when user specifies invalid values.)

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?

Type: any (optional, default: 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.


description?

Type: string (optional, default: No description for the parameter.)

A string of up to 4000 characters that describes the parameter.


maxLength?

Type: number (optional, default: None.)

An integer value that determines the largest number of characters you want to allow for String types.


maxValue?

Type: number (optional, default: None.)

A numeric value that determines the largest numeric value you want to allow for Number types.


minLength?

Type: number (optional, default: None.)

An integer value that determines the smallest number of characters you want to allow for String types.


minValue?

Type: number (optional, default: None.)

A numeric value that determines the smallest numeric value you want to allow for Number types.


noEcho?

Type: boolean (optional, default: 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 (*****).


type?

Type: string (optional, default: String)

The data type for the parameter (DataType).

Properties

NameTypeDescription
creationStackstring[]
defaultanyA value of the appropriate type for the template to use if no value is specified when a stack is created.
logicalIdstringThe logical ID for this CloudFormation stack element.
noEchobooleanIndicates if this parameter is configured with "NoEcho" enabled.
nodeNodeThe tree node.
stackStackThe stack in which this element is defined.
typestringThe data type for the parameter (DataType).
valueIResolvableThe parameter value as a Token.
valueAsListstring[]The parameter value, if it represents a string list.
valueAsNumbernumberThe parameter value, if it represents a number.
valueAsStringstringThe parameter value, if it represents a string.
allowedPattern?stringA regular expression that represents the patterns to allow for String types.
allowedValues?string[]An array containing the list of values allowed for the parameter.
constraintDescription?stringA string that explains a constraint when the constraint is violated.
description?stringA string of up to 4000 characters that describes the parameter.
maxLength?numberAn integer value that determines the largest number of characters you want to allow for String types.
maxValue?numberA numeric value that determines the largest numeric value you want to allow for Number types.
minLength?numberAn integer value that determines the smallest number of characters you want to allow for String types.
minValue?numberA numeric value that determines the smallest numeric value you want to allow for Number types.

creationStack

Type: string[]


default

Type: 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.


logicalId

Type: string

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


noEcho

Type: boolean

Indicates if this parameter is configured with "NoEcho" enabled.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this element is defined.

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


type

Type: string

The data type for the parameter (DataType).


value

Type: IResolvable

The parameter value as a Token.


valueAsList

Type: string[]

The parameter value, if it represents a string list.


valueAsNumber

Type: number

The parameter value, if it represents a number.


valueAsString

Type: string

The parameter value, if it represents a string.


allowedPattern?

Type: string (optional, default: No constraints on patterns allowed for parameter.)

A regular expression that represents the patterns to allow for String types.


allowedValues?

Type: string[] (optional, default: No constraints on values allowed for parameter.)

An array containing the list of values allowed for the parameter.


constraintDescription?

Type: string (optional, default: No description with customized error message when user specifies invalid values.)

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:


description?

Type: string (optional, default: No description for the parameter.)

A string of up to 4000 characters that describes the parameter.


maxLength?

Type: number (optional, default: None.)

An integer value that determines the largest number of characters you want to allow for String types.


maxValue?

Type: number (optional, default: None.)

A numeric value that determines the largest numeric value you want to allow for Number types.


minLength?

Type: number (optional, default: None.)

An integer value that determines the smallest number of characters you want to allow for String types.


minValue?

Type: number (optional, default: None.)

A numeric value that determines the smallest numeric value you want to allow for Number types.

Methods

NameDescription
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
resolve(_context)
toString()Returns a string representation of this construct.

overrideLogicalId(newLogicalId)

public overrideLogicalId(newLogicalId: string): void

Parameters

  • newLogicalId string — The new logical ID to use for this stack element.

Overrides the auto-generated logical ID with a specific ID.


resolve(_context)

public resolve(_context: IResolveContext): any

Parameters

  • _context IResolveContext

Returns

  • any

toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.