runway.variables module

Runway variables.

class runway.variables.Variable[source]

Bases: object

Represents a variable provided to a Runway directive.

__init__(name: str, value: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Initialize class.

Parameters
  • name – Name of the variable (directive/key).

  • value – The variable itself.

  • variable_type – Type of variable (cfngin|runway).

property dependencies: Set[str]

Stack names that this variable depends on.

Returns

Stack names that this variable depends on.

Return type

Set[str]

property resolved: bool

Boolean for whether the Variable has been resolved.

Variables only need to be resolved if they contain lookups.

property value: Any

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

FailedVariableLookup

get(key: str, default: Any = None) Any[source]

Implement evaluation of self.get.

Parameters
  • key – Attribute name to return the value for.

  • default – Value to return if attribute is not found.

__repr__() str[source]

Return object representation.

__new__(**kwargs)
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: Set[Any]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

Raises

NotImplementedError – Should be defined in a subclass.

property simplified: Any

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: Any

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: runway.variables._PydanticModelTypeVar, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValuePydanticModel[runway.variables._PydanticModelTypeVar][source]
classmethod parse_obj(obj: Dict[str, Any], variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue
classmethod parse_obj(obj: List[Any], variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValueList
classmethod parse_obj(obj: int, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValueLiteral[int]
classmethod parse_obj(obj: str, variable_type: Literal['cfngin', 'runway'] = 'cfngin') 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).

__iter__() Iterator[Any][source]

How the object is iterated.

Raises

NotImplementedError – Should be defined in a subclass.

__repr__() str[source]

Return object representation.

Raises

NotImplementedError – Should be defined in a subclass.

__init__()
__new__(**kwargs)
class runway.variables.VariableValueDict[source]

Bases: runway.variables.VariableValue, MutableMapping[str, runway.variables.VariableValue]

A dict variable value.

__init__(data: Dict[str, Any], variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Instantiate class.

Parameters
  • data – Data to be stored in the object.

  • variable_type – Type of variable (cfngin|runway).

property dependencies: Set[str]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

property simplified: Dict[str, Any]

Return a simplified version of the value.

This can be used to concatenate two literals into one literal or flatten nested concatenations.

property value: Dict[str, Any]

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.

__delitem__(_VariableValueDict__key: str) None[source]

Delete item by index.

__getitem__(_VariableValueDict__key: str) runway.variables.VariableValue[source]

Get item by index.

__iter__() Iterator[str][source]

How the object is iterated.

__len__() int[source]

Length of the object.

__repr__() str[source]

Return object representation.

__setitem__(_VariableValueDict__key: str, _VariableValueDict__value: runway.variables.VariableValue) None[source]

Set item by index.

__new__(**kwargs)
clear() None.  Remove all items from D.
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
class runway.variables.VariableValueList[source]

Bases: runway.variables.VariableValue, MutableSequence[runway.variables.VariableValue]

List variable value.

__init__(iterable: Iterable[Any], variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Instantiate class.

Parameters
  • iterable – Data to store in the iterable.

  • variable_type – Type of variable (cfngin|runway).

property dependencies: Set[str]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

property simplified: List[runway.variables.VariableValue]

Return a simplified version of the value.

This can be used to concatenate two literals into one literal or flatten nested concatenations.

property value: List[Any]

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.

__delitem__(_VariableValueList__index: int) None[source]

Delete item by index.

__getitem__(__index: int) runway.variables.VariableValue[source]
__getitem__(__index: slice) List[runway.variables.VariableValue]

Get item by index.

__setitem__(__index: int, __value: runway.variables.VariableValue) None[source]
__setitem__(__index: slice, __value: List[runway.variables.VariableValue]) None

Set item by index.

__iter__() Iterator[runway.variables.VariableValue][source]

Object iteration.

__len__() int[source]

Length of the object.

__repr__() str[source]

Object string representation.

__new__(**kwargs)
append(value)

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S
count(value) integer -- return number of occurrences of value
extend(values)

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

pop([index]) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

class runway.variables.VariableValueLiteral[source]

Bases: Generic[runway.variables._LiteralValue], runway.variables.VariableValue

The literal value of a variable as provided.

__init__(value: runway.variables._LiteralValue, variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Instantiate class.

Parameters
  • value – Data to store in the object.

  • variable_type – Type of variable (cfngin|runway).

property resolved: bool

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: runway.variables._LiteralValue

Value of the variable.

__iter__() Iterator[Any][source]

How the object is iterated.

__repr__() str[source]

Return object representation.

__new__(**kwargs)
property dependencies: Set[Any]

Stack names that this variable depends on.

classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

resolve(context: Union[CfnginContext, RunwayContext], provider: Optional[Provider] = None, variables: Optional[RunwayVariablesDefinition] = None, **kwargs: Any) None

Resolve the variable value.

Parameters
  • context – The current context object.

  • provider – Subclass of the base provider.

  • variables – Object containing variables passed to Runway.

property simplified: Any

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.

class runway.variables.VariableValueConcatenation[source]

Bases: Generic[runway.variables._VariableValue], runway.variables.VariableValue

A concatenated variable values.

__init__(iterable: Iterable[runway.variables._VariableValue], variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Instantiate class.

Parameters
  • iterable – Data to store in the iterable.

  • variable_type – Type of variable (cfngin|runway).

property dependencies: Set[str]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

property simplified: runway.variables.VariableValue

Return a simplified version of the value.

This can be used to concatenate two literals into one literal or flatten nested concatenations.

property value: Any

Value of the variable. Can be resolved or unresolved.

Raises

InvalidLookupConcatenation

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.

__delitem__(_VariableValueConcatenation__index: int) None[source]

Delete item by index.

__getitem__(__index: int) runway.variables._VariableValue[source]
__getitem__(__index: slice) List[runway.variables._VariableValue]

Get item by index.

__setitem__(__index: int, __value: runway.variables._VariableValue) None[source]
__setitem__(__index: slice, __value: List[runway.variables._VariableValue]) None

Set item by index.

__iter__() Iterator[runway.variables._VariableValue][source]

Object iteration.

__len__() int[source]

Length of the object.

__repr__() str[source]

Return object representation.

__new__(**kwargs)
classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

class runway.variables.VariableValueLookup[source]

Bases: runway.variables.VariableValue

A lookup variable value.

__init__(lookup_name: runway.variables.VariableValueLiteral[str], lookup_query: Union[str, runway.variables.VariableValue], handler: Optional[Type[runway.lookups.handlers.base.LookupHandler]] = None, variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

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
property dependencies: Set[str]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

property simplified: runway.variables.VariableValueLookup

Return a simplified version of the value.

This can be used to concatenate two literals into one literal or flatten nested concatenations.

property value: Any

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.

__iter__() Iterator[runway.variables.VariableValueLookup][source]

How the object is iterated.

__new__(**kwargs)
__repr__() str[source]

Return object representation.

classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

__str__() str[source]

Object displayed as a string.

class runway.variables.VariableValuePydanticModel[source]

Bases: Generic[runway.variables._PydanticModelTypeVar], runway.variables.VariableValue

A pydantic model variable value.

__new__(**kwargs)
classmethod parse_obj(obj: Any, variable_type: Literal['cfngin', 'runway'] = 'cfngin') runway.variables.VariableValue

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

__init__(data: runway.variables._PydanticModelTypeVar, variable_type: Literal['cfngin', 'runway'] = 'cfngin') None[source]

Instantiate class.

Parameters
  • data – Data to be stored in the object.

  • variable_type – Type of variable (cfngin|runway).

property dependencies: Set[str]

Stack names that this variable depends on.

property resolved: bool

Use to check if the variable value has been resolved.

property simplified: Dict[str, Any]

Return a simplified version of the value.

This can be used to concatenate two literals into one literal or flatten nested concatenations.

property value: runway.variables._PydanticModelTypeVar

Value of the variable. Can be resolved or unresolved.

Uses the original pydantic model class to parse the resolved data back into a pydantic model.

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.

__delitem__(_VariableValuePydanticModel__key: str) None[source]

Delete item by index.

__getitem__(_VariableValuePydanticModel__key: str) runway.variables.VariableValue[source]

Get item by index.

__iter__() Iterator[str][source]

How the object is iterated.

__len__() int[source]

Length of the object.

__repr__() str[source]

Return object representation.

__setitem__(_VariableValuePydanticModel__key: str, _VariableValuePydanticModel__value: runway.variables.VariableValue) None[source]

Set item by index.