class CfnCondition (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.CfnCondition |
Go | github.com/aws/aws-cdk-go/awscdk/v2#CfnCondition |
Java | software.amazon.awscdk.CfnCondition |
Python | aws_cdk.CfnCondition |
TypeScript (source) | aws-cdk-lib » CfnCondition |
Implements
IConstruct
, IDependable
, ICfn
, 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
Cfn
Condition Props
Build a new condition.
The condition must be constructed with a condition token, that the condition is based on.
Construct Props
Name | Type | Description |
---|---|---|
expression? | ICfn | The expression that the condition will evaluate. |
expression?
Type:
ICfn
(optional, default: None.)
The expression that the condition will evaluate.
Properties
Name | Type | Description |
---|---|---|
creation | string[] | |
logical | string | The logical ID for this CloudFormation stack element. |
node | Node | The tree node. |
stack | Stack | The stack in which this element is defined. |
expression? | ICfn | The 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:
ICfn
(optional)
The condition statement.
Methods
Name | Description |
---|---|
override | Overrides the auto-generated logical ID with a specific ID. |
resolve(_context) | Synthesizes the condition. |
to | 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
IResolve
Context
Returns
any
Synthesizes the condition.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.