Source code for runway.cfngin.lookups.handlers.xref
"""Handler for fetching outputs from fully qualified stacks."""from__future__importannotationsimportloggingfromtypingimportTYPE_CHECKING,Any,ClassVarfrom....lookups.handlers.baseimportLookupHandlerfrom.outputimportdeconstructifTYPE_CHECKING:from...providers.aws.defaultimportProviderLOGGER=logging.getLogger(__name__)XREF_PERSISTENT_STATE={"has_warned":False}
[docs]classXrefLookup(LookupHandler[Any]):"""Xref lookup."""DEPRECATION_MSG="xref Lookup has been deprecated; use the cfn lookup instead"TYPE_NAME:ClassVar[str]="xref""""Name that the Lookup is registered as."""
[docs]@classmethoddefhandle(cls,value:str,*_args:Any,provider:Provider,**_kwargs:Any)->str:"""Fetch an output from the designated, fully qualified stack. The `output` handler supports fetching outputs from stacks created within a single config file. Sometimes it's useful to fetch outputs from stacks created outside of the current config file. `xref` supports this by **not** using the :class:`runway.context.CfnginContext` to expand the fqn of the stack. Args: value: Parameter(s) given to this lookup. ``<stack_name>::<output_name>`` provider: Provider instance. Returns: Output from the specified stack. Example: :: conf_value: ${xref fully-qualified-stack-name::SomeOutputName} """decon=deconstruct(value)stack_fqn=decon.stack_namereturnprovider.get_output(stack_fqn,decon.output_name)