# CfnParameter

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.

Extends: Construct › CfnElement › CfnParameter
Implements: IConstruct, IDependable

- Source: [`core/lib/cfn-parameter.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/core/lib/cfn-parameter.ts#L102)

## Example

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

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

## Initializer

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

## Construct Props

- `allowedPattern`: string — A regular expression that represents the patterns to allow for String types.

  **Default:** No constraints on patterns allowed for parameter.

- `allowedValues`: string[] — An array containing the list of values allowed for the parameter.

  **Default:** No constraints on values allowed for parameter.

- `constraintDescription`: string — A string that explains a constraint when the constraint is violated.

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

  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`: any — A value of the appropriate type for the template to use if no value is specified when a stack is created.

  **Default:** No default value for parameter.

  If you define constraints for the parameter, you must specify
  a value that adheres to those constraints.

- `description`: string — A string of up to 4000 characters that describes the parameter.

  **Default:** No description for the parameter.

- `maxLength`: number = None. — An integer value that determines the largest number of characters you want to allow for String types.

- `maxValue`: number = None. — A numeric value that determines the largest numeric value you want to allow for Number types.

- `minLength`: number = None. — An integer value that determines the smallest number of characters you want to allow for String types.

- `minValue`: number = None. — A numeric value that determines the smallest numeric value you want to allow for Number types.

- `noEcho`: boolean — Whether to mask the parameter value when anyone makes a call that describes the stack.

  **Default:** Parameter values are not masked.

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

- `type`: string = String — The data type for the parameter (DataType).

## Properties

- `allowedPattern`: string — A regular expression that represents the patterns to allow for String types.

  **Default:** No constraints on patterns allowed for parameter.

- `allowedValues`: string[] — An array containing the list of values allowed for the parameter.

  **Default:** No constraints on values allowed for parameter.

- `constraintDescription`: string — A string that explains a constraint when the constraint is violated.

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

  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:

- `creationStack`: string[]

- `default`: any — A value of the appropriate type for the template to use if no value is specified when a stack is created.

  **Default:** No default value for parameter.

  If you define constraints for the parameter, you must specify
  a value that adheres to those constraints.

- `description`: string — A string of up to 4000 characters that describes the parameter.

  **Default:** No description for the parameter.

- `logicalId`: 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)`.

- `maxLength`: number = None. — An integer value that determines the largest number of characters you want to allow for String types.

- `maxValue`: number = None. — A numeric value that determines the largest numeric value you want to allow for Number types.

- `minLength`: number = None. — An integer value that determines the smallest number of characters you want to allow for String types.

- `minValue`: number = None. — A numeric value that determines the smallest numeric value you want to allow for Number types.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `noEcho`: boolean — Indicates if this parameter is configured with "NoEcho" enabled.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this element is defined.

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

- `type`: string = String — The data type for the parameter (DataType).

- `value`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — The parameter value as a Token.

- `valueAsList`: string[] — The parameter value, if it represents a string list.

- `valueAsNumber`: number — The parameter value, if it represents a number.

- `valueAsString`: string — The parameter value, if it represents a string.

## Methods

- `isCfnElement(x: any): boolean` (static) — 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:** The construct as a stack element or undefined if it is not a stack element.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  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**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `overrideLogicalId(newLogicalId: string): void` — Overrides the auto-generated logical ID with a specific ID.

  **Parameters**

  - `newLogicalId` — The new logical ID to use for this stack element.

- `resolve(_context: IResolveContext): any`

- `toString(): string` — Returns a string representation of this construct.

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