runway.variables module¶
Runway variables.
-
class
runway.variables.
Variable
(name: str, value: Any, variable_type: typing_extensions.Literal[cfngin, runway] = 'cfngin')[source]¶ Bases:
object
Represents a variable provided to a Runway directive.
Initialize class.
- Parameters
name – Name of the variable (directive/key).
value – The variable itself.
variable_type – Type of variable (cfngin|runway).
-
property
dependencies
¶ Stack names that this variable depends on.
- Returns
Stack names that this variable depends on.
- Return type
Set[str]
-
property
resolved
¶ Boolean for whether the Variable has been resolved.
Variables only need to be resolved if they contain lookups.
-
property
value
¶ Return the current value of the Variable.
- Raises
UnresolvedVariable – Value accessed before it have been resolved.
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
- Raises
-
runway.variables.
resolve_variables
(variables: List[Variable], context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None) → None[source]¶ Given a list of variables, resolve all of them.
- Parameters
variables – List of variables.
context – CFNgin context.
provider – Subclass of the base provider.
-
class
runway.variables.
VariableValue
[source]¶ Bases:
object
Syntax tree base class to parse variable values.
-
property
dependencies
¶ Stack names that this variable depends on.
-
property
resolved
¶ Use to check if the variable value has been resolved.
- Raises
NotImplementedError – Should be defined in a subclass.
-
property
simplified
¶ Return a simplified version of the value.
This can be used to concatenate two literals into one literal or flatten nested concatenations.
Should be implimented in subclasses where applicable.
-
property
value
¶ Value of the variable. Can be resolved or unresolved.
- Raises
NotImplementedError – Should be defined in a subclass.
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
-
classmethod
parse_obj
(obj: Dict[str, Any], variable_type: typing_extensions.Literal[cfngin, runway] = '...') → runway.variables.VariableValue[source]¶ -
classmethod
parse_obj
(obj: List[Any], variable_type: typing_extensions.Literal[cfngin, runway] = '...') → runway.variables.VariableValueList -
classmethod
parse_obj
(obj: int, variable_type: typing_extensions.Literal[cfngin, runway] = '...') → runway.variables.VariableValueLiteral[int] -
classmethod
parse_obj
(obj: str, variable_type: typing_extensions.Literal[cfngin, runway] = '...') → runway.variables.VariableValueConcatenation[Union[runway.variables.VariableValueLiteral[str], runway.variables.VariableValueLookup]] Parse complex variable structures using type appropriate subclasses.
- Parameters
obj – The objected defined as the value of a variable.
variable_type – Type of variable (cfngin|runway).
-
property
-
class
runway.variables.
VariableValueDict
(*args, **kwds)[source]¶ Bases:
runway.variables.VariableValue
,collections.abc.MutableMapping
,typing.Generic
A dict variable value.
Instantiate class.
- Parameters
data – Data to be stored in the object.
variable_type – Type of variable (cfngin|runway).
-
property
dependencies
¶ Stack names that this variable depends on.
-
property
resolved
¶ Use to check if the variable value has been resolved.
-
property
simplified
¶ Return a simplified version of the value.
This can be used to concatenate two literals into one literal or flatten nested concatenations.
-
property
value
¶ Value of the variable. Can be resolved or unresolved.
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
-
class
runway.variables.
VariableValueList
(*args, **kwds)[source]¶ Bases:
runway.variables.VariableValue
,collections.abc.MutableSequence
,typing.Generic
List variable value.
Instantiate class.
- Parameters
iterable – Data to store in the iterable.
variable_type – Type of variable (cfngin|runway).
-
property
dependencies
¶ Stack names that this variable depends on.
-
property
resolved
¶ Use to check if the variable value has been resolved.
-
property
simplified
¶ Return a simplified version of the value.
This can be used to concatenate two literals into one literal or flatten nested concatenations.
-
property
value
¶ Value of the variable. Can be resolved or unresolved.
-
insert
(index: int, value: runway.variables.VariableValue) → None[source]¶ Insert a value at a specific index.
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
-
class
runway.variables.
VariableValueLiteral
(*args, **kwds)[source]¶ Bases:
typing.Generic
,runway.variables.VariableValue
The literal value of a variable as provided.
Instantiate class.
- Parameters
value – Data to store in the object.
variable_type – Type of variable (cfngin|runway).
-
property
resolved
¶ Use to check if the variable value has been resolved.
The ValueLiteral will always appear as resolved because it does not “resolve” since it is the literal definition of the value.
-
property
value
¶ Value of the variable.
-
class
runway.variables.
VariableValueConcatenation
(*args, **kwds)[source]¶ Bases:
typing.Generic
,runway.variables.VariableValue
A concatinated variable values.
Instantiate class.
- Parameters
iterable – Data to store in the iterable.
variable_type – Type of variable (cfngin|runway).
-
property
dependencies
¶ Stack names that this variable depends on.
-
property
resolved
¶ Use to check if the variable value has been resolved.
-
property
simplified
¶ Return a simplified version of the value.
This can be used to concatenate two literals into one literal or flatten nested concatentations.
-
property
value
¶ Value of the variable. Can be resolved or unresolved.
- Raises
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
-
class
runway.variables.
VariableValueLookup
(lookup_name: runway.variables.VariableValueLiteral[str], lookup_query: Union[str, runway.variables.VariableValue], handler: Optional[Type[runway.lookups.handlers.base.LookupHandler]] = None, variable_type: typing_extensions.Literal[cfngin, runway] = 'cfngin')[source]¶ Bases:
runway.variables.VariableValue
A lookup variable value.
Initialize class.
- Parameters
lookup_name – Name of the invoked lookup.
lookup_query – Data portion of the lookup.
handler – Lookup handler that will be use to resolve the value.
variable_type – Type of variable (cfngin|runway).
- Raises
UnknownLookupType – Invalid lookup type.
ValueError – Invalid value for variable_type.
-
lookup_name
: runway.variables.VariableValueLiteral[str]¶
-
lookup_query
: runway.variables.VariableValue¶
-
handler
: Type[runway.lookups.handlers.base.LookupHandler]¶
-
property
dependencies
¶ Stack names that this variable depends on.
-
property
resolved
¶ Use to check if the variable value has been resolved.
-
property
simplified
¶ Return a simplified version of the value.
This can be used to concatenate two literals into one literal or flatten nested concatenations.
-
property
value
¶ Value of the variable. Can be resolved or unresolved.
- Raises
UnresolvedVariableValue – Value accessed before it has been resolved.
-
resolve
(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) → None[source]¶ Resolve the variable value.
- Parameters
context – The current context object.
provider – Subclass of the base provider.
variables – Object containing variables passed to Runway.
- Raises
FailedLookup – A lookup failed for any reason.