Skip to content
v2.274.0

Reference Class ​

An intrinsic Token that represents a reference to a construct.

References are recorded.

Initializer ​

ts
new Reference(value: any, target: IConstruct, displayName?: string, typeHint?: ResolutionTypeHint)
python
Reference(value: Any, target: IConstruct, display_name: typing.Optional[str] = None, type_hint: typing.Optional[ResolutionTypeHint] = None)
java
new Reference(Object value, IConstruct target, String displayName, ResolutionTypeHint typeHint)
csharp
new Reference(object value, IConstruct target, string? displayName = null, ResolutionTypeHint? typeHint = null)
go
NewReference(Value interface{}, Target IConstruct, DisplayName *string, TypeHint ResolutionTypeHint)

Properties ​

creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#
The captured stack trace which represents the location in which this token was created.
displayNamestringdisplay_namestrdisplayNameStringDisplayNamestringDisplayName*stringrequired#
targetIConstructtargetIConstructtargetIConstructTargetIConstructTargetIConstructrequired#
Type that the Intrinsic is expected to evaluate to.

Methods ​

isReference(x: any): boolean@staticmethod def is_reference(x: Any) -> boolpublic static Boolean isReference(Object x)public static bool IsReference(object x)func IsReference(X interface{}) *boolstatic#
Check whether this is actually a Reference.
resolve(_context: IResolveContext): anydef resolve(self, _context: IResolveContext) -> Anypublic Object resolve(IResolveContext _context)public object Resolve(IResolveContext _context)func Resolve(_context IResolveContext) interface{}#
Produce the Token's value at resolution time.
toJSON(): anydef to_json(self, ) -> Anypublic Object toJSON()public object ToJSON()func ToJSON() interface{}#
Turn this Token into JSON.

Called automatically when JSON.stringify() is called on a Token.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Convert an instance of this Token to a string.

This method will be called implicitly by language runtimes if the object is embedded into a string. We treat it the same as an explicit stringification.

toStringList(): string[]def to_string_list(self, ) -> typing.List[str]public List<String> toStringList()public string[] ToStringList()func ToStringList() *[]*string#
Convert an instance of this Token to a string list.

This method will be called implicitly by language runtimes if the object is embedded into a list. We treat it the same as an explicit stringification.