runway.variables module

Runway variables.

class runway.variables.Variable(name: str, value: typing.Any, variable_type: 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

FailedVariableLookup

get(key: str, default: Optional[typing.Any] = None)typing.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.

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: Literal[cfngin, runway] = 'cfngin')runway.variables.VariableValue[source]
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[typing.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.

class runway.variables.VariableValueDict(data: Dict[str, Any], variable_type: VariableTypeLiteralTypeDef = 'cfngin')[source]

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

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.

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

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: typing.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(iterable: Iterable[typing.Any], variable_type: Literal[cfngin, runway] = 'cfngin')[source]

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

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.

__delitem__(_VariableValueList__index: int)None[source]

Delete item by index.

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

Get item by index.

__setitem__(__index: int, __value: runway.variables.VariableValue)None[source]
__setitem__(__index: slice, __value: List[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.

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: typing.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(value: _LiteralValue, variable_type: Literal[cfngin, runway] = 'cfngin')[source]

Bases: Generic[runway.variables._LiteralValue], 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.

__iter__()Iterator[typing.Any][source]

How the object is iterated.

__repr__()str[source]

Return object representation.

property dependencies

Stack names that this variable depends on.

classmethod parse_obj(obj: typing.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

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(iterable: Iterable[_VariableValue], variable_type: Literal[cfngin, runway] = 'cfngin')[source]

Bases: Generic[runway.variables._VariableValue], 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

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)_VariableValue[source]
__getitem__(__index: slice)List[_VariableValue]

Get item by index.

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

Set item by index.

__iter__()Iterator[_VariableValue][source]

Object iteration.

__len__()int[source]

Length of the object.

__repr__()str[source]

Return object representation.

classmethod parse_obj(obj: typing.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(lookup_name: VariableValueLiteral[str], lookup_query: Union[str, VariableValue], handler: Optional[Type[LookupHandler]] = None, variable_type: VariableTypeLiteralTypeDef = '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
classmethod parse_obj(obj: typing.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).

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.

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

How the object is iterated.

__repr__()str[source]

Return object representation.

__str__()str[source]

Object displayed as a string.