aws-cdk-lib.CfnCondition

class CfnCondition (construct)

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

Implements IConstruct, IDependable, ICfnConditionExpression, IResolvable

Represents a CloudFormation condition, for resources which must be conditionally created and the determination must be made at deploy time.

Example

const rawBucket = new s3.CfnBucket(this, 'Bucket', { /* ... */ });
// -or-
const rawBucketAlt = myBucket.node.defaultChild as s3.CfnBucket;

// then
rawBucket.cfnOptions.condition = new CfnCondition(this, 'EnableBucket', { /* ... */ });
rawBucket.cfnOptions.metadata = {
  metadataKey: 'MetadataValue',
};

Initializer

new CfnCondition(scope: Construct, id: string, props?: CfnConditionProps)

Parameters

  • scope Construct
  • id string
  • props CfnConditionProps

Build a new condition.

The condition must be constructed with a condition token, that the condition is based on.

Construct Props

NameTypeDescription
expression?ICfnConditionExpressionThe expression that the condition will evaluate.

expression?

Type: ICfnConditionExpression (optional, default: None.)

The expression that the condition will evaluate.

Properties

NameTypeDescription
creationStackstring[]
logicalIdstringThe logical ID for this CloudFormation stack element.
nodeNodeThe tree node.
stackStackThe stack in which this element is defined.
expression?ICfnConditionExpressionThe condition statement.

creationStack

Type: string[]


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


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


expression?

Type: ICfnConditionExpression (optional)

The condition statement.

Methods

NameDescription
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
resolve(_context)Synthesizes the condition.
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

Synthesizes the condition.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.