runway.lookups.handlers.cfn module
Retrieve a value from CloudFormation Stack Outputs.
The query syntax for this lookup is <stack-name>.<output-name>
.
When specifying the output name, be sure to use the Logical ID of
the output; not the Export.Name.
- class runway.lookups.handlers.cfn.OutputQuery[source]
Bases:
NamedTuple
Output query NamedTuple.
- __init__()
- static __new__(_cls, stack_name: str, output_name: str)
Create new instance of OutputQuery(stack_name, output_name)
- count(value, /)
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
- class runway.lookups.handlers.cfn.CfnLookup[source]
Bases:
runway.lookups.handlers.base.LookupHandler
CloudFormation Stack Output lookup.
- TYPE_NAME: Final[Literal['cfn']] = 'cfn'
Name that the Lookup is registered as.
- static should_use_provider(args: Dict[str, str], provider: Optional[Provider]) bool [source]
Determine if the provider should be used for the lookup.
This will open happen when the lookup is used with CFNgin.
- Parameters
args – Parsed arguments provided to the lookup.
provider – CFNgin provider.
- static get_stack_output(client: CloudFormationClient, query: OutputQuery) str [source]
Get CloudFormation Stack output.
- Parameters
client – Boto3 CloudFormation client.
query – What to get.
- __init__()
- __new__(**kwargs)
- classmethod dependencies(_LookupHandler__lookup_query: VariableValue) Set[str]
Calculate any dependencies required to perform this lookup.
Note that lookup_query may not be (completely) resolved at this time.
- classmethod format_results(value: Any, get: Optional[str] = None, load: Optional[str] = None, transform: Optional[Literal['bool', 'str']] = None, **kwargs: Any) Any
Format results to be returned by a lookup.
- Parameters
value – Data collected by the Lookup.
get – Nested value to get from a dictionary like object.
load – Parser to use to parse a formatted string before the
get
andtransform
method.transform – Convert the final value to a different data type before returning it.
- Raises
TypeError – If
get
is provided but the value value is not a dictionary like object.
Runs the following actions in order:
load()
ifload
is provided.runway.util.MutableMap.find()
ordict.get()
depending on the data type ifget
is provided.Convert null value string to
NoneType
object. This includes string values of “None” and “null”. This conversion is case insensitive.transform()
iftransform
is provided.
- classmethod handle(value: str, context: Union[CfnginContext, RunwayContext], *, provider: Optional[Provider] = None, **_: Any) Any [source]
Retrieve a value from CloudFormation Stack outputs.
- Parameters
value – The value passed to the Lookup.
context – The current context object.
provider – AWS provider.
- Returns
Result of the query.
- Raises
OutputDoesNotExist – Output does not exist on the Stack provided and default was not provided.
- classmethod load(value: Any, parser: Optional[str] = None, **kwargs: Any) Any
Load a formatted string or object into a python data type.
First action taken in
format_results()
. If a lookup needs to handling loading data to process it before it entersformat_results()
, is should useargs.pop('load')
to prevent the data from being loaded twice.- Parameters
value – What is being loaded.
parser – Name of the parser to use.
- Returns
The loaded value.
- classmethod parse(value: str) Tuple[str, Dict[str, str]]
Parse the value passed to a lookup in a standardized way.
- Parameters
value – The raw value passed to a lookup.
- Returns
The lookup query and a dict of arguments
- classmethod transform(value: Any, *, to_type: Optional[Literal['bool', 'str']] = 'str', **kwargs: Any) Any
Transform the result of a lookup into another datatype.
Last action taken in
format_results()
. If a lookup needs to handling transforming the data in a way that the base class can’t support it should overwrite this method of the base class to register different transform methods.- Parameters
value – What is to be transformed.
to_type – The type the value will be transformed into.
- Returns
The transformed value.