aws-vapor

DSL

Template Root

class aws_vapor.dsl.Template(version: str = '2010-09-09', description: str = '')[source]

An AWS CloudFormation template builder.

conditions(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
description(description: str) → aws_vapor.dsl.Template[source]
mappings(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
metadata(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
outputs(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
parameters(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
resources(element: aws_vapor.dsl.Element, merge: bool = False) → aws_vapor.dsl.Element[source]
to_template() → collections.OrderedDict[source]

Elements

class aws_vapor.dsl.Element(name: str)[source]

This is an abstract base class of a template section.

attributes(name: str, value: Any)[source]

Map name to value and return self.

to_template(template: Dict[str, Any])[source]

Convert mapped key-value pairs into a top level section of an AWS CloudFormation template.

Parameters:template – A template builder.
Returns:Passed a mapping object.
class aws_vapor.dsl.Metadatum(name: str)[source]

The Metadatum class is a subclass of Element, each instance of which represents details about the template.

class aws_vapor.dsl.Parameter(name: str)[source]

The Parameter class is a subclass of Element, each instance of which passes values into your template when you create a stack.

allowed_pattern(pattern: str) → aws_vapor.dsl.Parameter[source]

Set ‘AllowedPattern’ to pattern and return self.

allowed_values(list_of_values: List[Any]) → aws_vapor.dsl.Parameter[source]

Set ‘AllowedValues’ to list_of_values and return self.

constraint_description(desc: str) → aws_vapor.dsl.Parameter[source]

Set ‘ConstraintDescription’ to desc and return self.

default(value: Any) → aws_vapor.dsl.Parameter[source]

Set ‘Default’ to value and return self.

description(desc: str) → aws_vapor.dsl.Parameter[source]

Set ‘Description’ to desc and return self.

max_length(length: int) → aws_vapor.dsl.Parameter[source]

Set ‘MaxLength’ to length and return self.

max_value(value: int) → aws_vapor.dsl.Parameter[source]

Set MaxValue to value and return self.

min_length(length: int) → aws_vapor.dsl.Parameter[source]

Set MinLength to length and return self.

min_value(value: int) → aws_vapor.dsl.Parameter[source]

Set MinValue to value and return self.

no_echo() → aws_vapor.dsl.Parameter[source]

Set ‘NoEcho’ to true and return self.

type(name: str) → aws_vapor.dsl.Parameter[source]

Set ‘Type’ to name and return self.

class aws_vapor.dsl.Mapping(name: str)[source]

The Mapping class is a subclass of Element, each instance of which matches a key to a corresponding set of named values.

add_category(category: str) → aws_vapor.dsl.Mapping[source]

Create a new top level section of ‘Mappings’ and return self.

Create a new top level section of ‘Mappings’ if doesn’t contain category, then set a current selection to category.

Parameters:category – A name of a top level section.
Returns:self.
add_item(key: str, value: Any) → aws_vapor.dsl.Mapping[source]

Map key to value in a current selection and return self.

find_in_map(top_level_key: str, second_level_key: str) → Dict[str, Any][source]

Call Intrinsics.find_in_map and return its return value.

class aws_vapor.dsl.Condition(name: str)[source]

The Condition class is a subclass of Element, each instance of which includes statements that define when a resource is created or when a property is defined.

expression(expression: Dict[str, Any]) → aws_vapor.dsl.Condition[source]

Set expression and return self.

to_template(template: Dict[str, Any])[source]

Convert self.attrs into a top level section of an AWS CloudFormation template.

Parameters:template – A template builder.
Returns:Passed a mapping object.
class aws_vapor.dsl.Resource(name: str)[source]

The Resource class is a subclass of Element, each instance of which declares the AWS resources that you want to include in the stack, such as an Amazon EC2 instance or an Amazon S3 bucket.

add_property(prop: Dict[str, Any]) → aws_vapor.dsl.Resource[source]

Add a new key-value pair to ‘Properties’ and return self.

condition(condition: aws_vapor.dsl.Condition) → aws_vapor.dsl.Resource[source]

Set ‘Condition’ to condition and return self.

depends_on(resource: aws_vapor.dsl.Resource) → aws_vapor.dsl.Resource[source]

Set ‘DependsOn’ to a name of resource and return self.

metadata(metadata: Any) → aws_vapor.dsl.Resource[source]

Set ‘Metadata’ to metadata and return self.

properties(props: List[Dict[str, Any]]) → aws_vapor.dsl.Resource[source]

Add a list of a new key-value pair to ‘Properties’ and return self.

Parameters:props – A list of a key-value pair.
Returns:self.
type(name: str) → aws_vapor.dsl.Resource[source]

Set ‘Type’ to name and return self.

class aws_vapor.dsl.Output(name: str)[source]

The Output class is a subclass of Element, each instance of which declares output values that you can import into other stacks (to create cross-stack references), return in response (to describe stack calls), or view on the AWS CloudFormation console.

condition(condition: aws_vapor.dsl.Condition) → aws_vapor.dsl.Output[source]
description(desc: str) → aws_vapor.dsl.Output[source]
export(name: str) → aws_vapor.dsl.Output[source]
value(value: Dict[str, Any]) → aws_vapor.dsl.Output[source]

Utilities

class aws_vapor.dsl.Attributes[source]
classmethod of(name: str, value: Any) → Dict[str, Any][source]
class aws_vapor.dsl.Intrinsics[source]
classmethod base64(value_to_encode: Any) → Dict[str, Any][source]
classmethod find_in_map(map_name_or_mapping: Union[str, Mapping], top_level_key: str, second_level_key: str) → Dict[str, Any][source]
classmethod fn_and(conditions: List[aws_vapor.dsl.Condition] = None) → Dict[str, Any][source]
classmethod fn_equals(value_1: Any, value_2: Any) → Dict[str, Any][source]
classmethod fn_if(condition_name: str, value_if_true: Any, value_if_false: Any) → Dict[str, Any][source]
classmethod fn_not(condition: aws_vapor.dsl.Condition) → Dict[str, Any][source]
classmethod fn_or(conditions: List[aws_vapor.dsl.Condition] = None) → Dict[str, Any][source]
classmethod get_att(logical_name_of_resource: str, attribute_name: str) → Dict[str, Any][source]
classmethod get_azs(region: str = '') → Dict[str, Any][source]
classmethod import_value(value_to_import: Any) → Dict[str, Any][source]
classmethod join(delimiter: str, list_of_values: List[Any]) → Dict[str, Any][source]
classmethod ref(logical_name_or_element: Union[str, Element]) → Dict[str, Any][source]
classmethod select(index: int, list_of_objects: List[Any]) → Dict[str, Any][source]
classmethod sub(template: str, dict_of_parameters: Dict[str, Any] = None) → Dict[str, Any][source]
class aws_vapor.dsl.Pseudos[source]
classmethod account_id() → Dict[str, Any][source]
classmethod no_value() → Dict[str, Any][source]
classmethod notification_arns() → Dict[str, Any][source]
classmethod region() → Dict[str, Any][source]
classmethod stack_id() → Dict[str, Any][source]
classmethod stack_name() → Dict[str, Any][source]
class aws_vapor.dsl.UserData[source]
classmethod from_files(files: List[Tuple[str, str]], params: Dict[str, Any]) → Dict[str, Any][source]
classmethod of(values: List[Any]) → Dict[str, Any][source]
class aws_vapor.dsl.CfnInitMetadata[source]
class Authentication(name: str, authentication_type: str)[source]
access_key_id(value: str) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
buckets(list_of_values: List[str]) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
password(value: str) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
role_name(value: str) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
secret_key(value: str) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
uris(list_of_values: List[str]) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
username(value: str) → aws_vapor.dsl.CfnInitMetadata.Authentication[source]
class Config(name: str)[source]
commands(key: str, command: str, env: Dict[str, Any] = None, cwd: str = None, test: str = None, ignore_errors: bool = None, wait_after_completion: int = None) → aws_vapor.dsl.CfnInitMetadata.Config[source]
files(key: str, content: Union[str, Dict[str, Any]] = None, source: str = None, local_file_path: str = None, encoding: str = None, group: str = None, owner: str = None, mode: str = None, authentication: str = None, context: str = None, local_file_params: str = None) → aws_vapor.dsl.CfnInitMetadata.Config[source]
groups(key: str, gid: int = None) → aws_vapor.dsl.CfnInitMetadata.Config[source]
packages(package_manager: str, key: str, versions: List[str] = None) → aws_vapor.dsl.CfnInitMetadata.Config[source]
services(service_manager: str, key: str, ensure_running: bool = None, enabled: bool = None, files: List[str] = None, sources: List[str] = None, packages: Dict[str, List[str]] = None, commands: List[str] = None) → aws_vapor.dsl.CfnInitMetadata.Config[source]
sources(key: str, url: str) → aws_vapor.dsl.CfnInitMetadata.Config[source]
users(key: str, uid: int, groups: List[str], home_dir: str) → aws_vapor.dsl.CfnInitMetadata.Config[source]
class ConfigSet(name, configs: List[CfnInitMetadata.Config])[source]
class Init(config_or_config_sets: List[Union[CfnInitMetadata.Config, CfnInitMetadata.ConfigSet]])[source]
classmethod of(list_of_metadata: List[Union[CfnInitMetadata.Init, CfnInitMetadata.Authentication]]) → collections.OrderedDict[source]

Utility Functions

aws_vapor.utils.combine_user_data(files: List[Tuple[str, str]]) → str[source]

Make a multipart/* message from a file content.

Parameters:files – Paths to a file, a content of which will be used as ‘UserData’.
Returns:A multipart/* message attached a file content to.
aws_vapor.utils.get_property_from_config_file(section: str, key: str, default_value: str = None) → str[source]

Get a property value from a config file.

Parameters:
  • section – A name of a section.
  • key – A name of a property.
  • default_value – A value will be returned when a property is not defined.
Returns:

A property value corresponding to the key, which is property name, in the section, or default_value if the section is not defined or the key is not defined.

aws_vapor.utils.inject_params(lines: str, params: dict) → List[str][source]

Replace placeholders with parameters.

Parameters:
  • lines – A file content including placeholders ({{ … }}).
  • params – A mapping a name of placeholders to a value.
Returns:

A file content replaced placeholders with parameters.

aws_vapor.utils.load_from_config_file(config_directories: List[str] = None) → dict[source]

Load properties from a config file.

Parameters:config_directories – A path to config directory having ‘config’. If not specified, locating ‘config’ on GLOBAL_CONFIG_DIRECTORY and LOCAL_CONFIG_DIRECTORY.
Returns:A mapping of properties loaded from a config file.

example:

{
    'section': {
        'key1': 'value1',
        'key2': 'value2'
    }
}
aws_vapor.utils.open_output_file(relative_file_path: str) → io.TextIOBase[source]

Open an output file.

Parameters:relative_file_path – A path to an output file.
Returns:A file descriptor of an output file.
aws_vapor.utils.save_to_config_file(props: dict, save_on_global: bool = False)[source]

Save properties to a config file.

Parameters:
  • props – A mapping of properties.
  • save_on_global – A flag whether or not a new configuration will be saved globally.