class aws_cdk.CfnRefElement(scope, id)

Bases: CfnElement

Base class for referencable CloudFormation constructs which are not Resources.

These constructs are things like Conditions and Parameters, can be referenced by taking the .ref attribute.

Resource constructs do not inherit from CfnRefElement because they have their own, more specific types returned from the .ref attribute. Also, some resources aren’t referencable at all (such as BucketPolicies or GatewayAttachments).

Creates an entity and binds it to a tree.

Note that the root of the tree must be a Stack object (not just any Root).

  • scope (Construct) – The parent construct.

  • id (str) –



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


new_logical_id (str) – The new logical ID to use for this stack element.

Return type:



Returns a string representation of this construct.

Return type:





the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.


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


the logical ID as a stringified token. This value will only get resolved during synthesis.


The tree node.


Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).


The stack in which this element is defined.

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

Static Methods

classmethod is_cfn_element(x)

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.


x (Any) –

Return type:



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

classmethod is_construct(x)

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.


x (Any) – Any object.

Return type:



true if x is an object created from a class which extends Construct.