runway.cfngin.blueprints.raw module

CFNgin blueprint representing raw template module.

runway.cfngin.blueprints.raw.get_template_path(file_path: pathlib.Path) Optional[pathlib.Path][source]

Find raw template in working directory or in sys.path.

template_path from config may refer to templates co-located with the CFNgin config, or files in remote package_sources. Here, we emulate python module loading to find the path to the template.

Parameters

filename – Template path.

Returns

Path to file, or None if no file found

runway.cfngin.blueprints.raw.resolve_variable(provided_variable: Optional[Variable], blueprint_name: str) Any[source]

Resolve a provided variable value against the variable definition.

This acts as a subset of resolve_variable logic in the base module, leaving out everything that doesn’t apply to CFN parameters.

Parameters
  • provided_variable – The variable value provided to the blueprint.

  • blueprint_name – The name of the blueprint that the variable is being applied to.

Raises

UnresolvedBlueprintVariable – Raised when the provided variable is not already resolved.

class runway.cfngin.blueprints.raw.RawTemplateBlueprint[source]

Bases: runway.cfngin.blueprints.base.Blueprint

Blueprint class for blueprints auto-generated from raw templates.

context

CFNgin context object.

description

The description of the CloudFormation template that will be generated by this Blueprint.

mappings

CloudFormation Mappings to be added to the template during the rendering process.

name

Name of the Stack that will be created by the Blueprint.

raw_template_path

Path to the raw CloudFormation template file.

Type

Path

__init__(name: str, context: runway.context.CfnginContext, *, description: Optional[str] = None, mappings: Optional[Dict[str, Any]] = None, raw_template_path: pathlib.Path, **_: Any) None[source]

Instantiate class.

Changed in version 2.0.0: Class only takes 2 positional arguments. The rest are now keyword arguments.

property output_definitions: Dict[str, Dict[str, Any]]

Get the output definitions.

New in version 2.0.0.

Returns

Output definitions. Keys are output names, the values are dicts containing key/values for various output properties.

property parameter_definitions: Dict[str, Any]

Get the parameter definitions to submit to CloudFormation.

New in version 2.0.0.

Returns

Parameter definitions. Keys are parameter names, the values are dicts containing key/values for various parameter properties.

property parameter_values: Dict[str, Union[List[Any], str]]

Return a dict of variables with type CFNType.

New in version 2.0.0.

Returns

Variables that need to be submitted as CloudFormation Parameters. Will be a dictionary of <parameter name>: <parameter value>.

property rendered: str

Return (generating first if needed) rendered template.

property requires_change_set: bool

Return True if the underlying template has transforms.

property version: str

Return (generating first if needed) version hash.

to_dict() Dict[str, Any][source]

Return the template as a python dictionary.

Returns

the loaded template as a python dictionary

Return type

dict

to_json(variables: Optional[Dict[str, Any]] = None) str[source]

Return the template in JSON.

Parameters

variables – Unused in this subclass (variables won’t affect the template).

render_template() Tuple[str, str][source]

Load template and generate its md5 hash.

__new__(**kwargs)
add_output(name: str, value: Any) None

Add an output to the template.

Wrapper for self.template.add_output(Output(name, Value=value)).

Parameters
  • name – The name of the output to create.

  • value – The value to put in the output.

property cfn_parameters: Dict[str, Union[List[Any], str]]

Return a dict of variables with type CFNType.

New in version 2.0.0.

Returns

Variables that need to be submitted as CloudFormation Parameters.

create_template() None

Abstract method called to create a template from the blueprint.

property defined_variables: Dict[str, BlueprintVariableTypeDef]

Return a copy of VARIABLES to avoid accidental modification of the ClassVar.

Changed in version 2.0.0: Changed from a method to a property.

get_cfn_parameters() Dict[str, Union[List[Any], str]]

Return a dictionary of variables with type CFNType.

Deprecated since version 2.0.0: Replaced by cfn_parameters.

Returns

Variables that need to be submitted as CloudFormation Parameters.

get_output_definitions() Dict[str, Dict[str, Any]]

Get the output definitions.

Deprecated since version 2.0.0: Replaced by output_definitions.

Returns

Output definitions. Keys are output names, the values are dicts containing key/values for various output properties.

get_parameter_definitions() Dict[str, BlueprintVariableTypeDef]

Get the parameter definitions to submit to CloudFormation.

Any variable definition whose type is an instance of CFNType will be returned as a CloudFormation Parameter.

Deprecated since version 2.0.0: Replaced by parameter_definitions.

Returns

Parameter definitions. Keys are parameter names, the values are dicts containing key/values for various parameter properties.

get_parameter_values() Dict[str, Union[List[Any], str]]

Return a dict of variables with type CFNType.

Deprecated since version 2.0.0: Replaced by parameter_values.

Returns

Variables that need to be submitted as CloudFormation Parameters. Will be a dictionary of <parameter name>: <parameter value>.

get_required_parameter_definitions() Dict[str, BlueprintVariableTypeDef]

Return all template parameters that do not have a default value.

Deprecated since version 2.0.0: Replaced by required_parameter_definitions.

Returns

Dict of required CloudFormation Parameters for the blueprint. Will be a dictionary of <parameter name>: <parameter attributes>.

get_variables() Dict[str, Any]

Return a dictionary of variables available to the template.

These variables will have been defined within VARIABLES or self.defined_variables. Any variable value that contains a lookup will have been resolved.

Deprecated since version 2.0.0: Replaced by variables.

Returns

Variables available to the template.

Raises

UnresolvedBlueprintVariables – If variables are unresolved.

import_mappings() None

Import mappings from CFNgin config to the blueprint.

read_user_data(user_data_path: str) str

Read and parse a user_data file.

Parameters

user_data_path – Path to the userdata file.

property required_parameter_definitions: Dict[str, BlueprintVariableTypeDef]

Return all template parameters that do not have a default value.

New in version 2.0.0.

Returns

Dict of required CloudFormation Parameters for the blueprint. Will be a dictionary of <parameter name>: <parameter attributes>.

reset_template() None

Reset template.

resolve_variables(provided_variables: List[Variable]) None[source]

Resolve the values of the blueprint variables.

This will resolve the values of the template parameters with values from the env file, the config, and any lookups resolved. The resolution is run twice, in case the blueprint is jinja2 templated and requires provided variables to render.

Parameters

provided_variables – List of provided variables.

set_template_description(description: str) None

Add a description to the Template.

Parameters

description – A description to be added to the resulting template.

setup_parameters() None

Add any CloudFormation parameters to the template.

property variables: Dict[str, Any]

Return a Dict of variables available to the Template.

These variables will have been defined within VARIABLES or defined_variables. Any variable value that contains a Lookup will have been resolved.

New in version 2.0.0.

Returns

Variables available to the Template.

Raises

UnresolvedBlueprintVariables – If variables are unresolved.