sceptre.template_handlers package

class sceptre.template_handlers.TemplateHandler(name, arguments=None, sceptre_user_data=None, connection_manager=None, stack_group_config=None)[source]

Bases: object

TemplateHandler is an abstract base class that should be inherited by all Template Handlers.

Parameters
  • name (str) – Name of the template

  • arguments (dict) – The arguments of the template handler

  • sceptre_user_data (dict) – Sceptre user data in stack config

  • connection_manager (sceptre.connection_manager.ConnectionManager) – Connection manager used to call AWS

  • stack_group_config (dict) – The Stack group config to use as defaults.

abstract handle()[source]

An abstract method which must be overwritten by all inheriting classes. This method is called to retrieve the template. Implementation of this method in subclasses must return a string that can be interpreted by Sceptre (CloudFormation YAML / JSON, Jinja or Python)

jinja_template_extensions = ['.j2']
python_template_extensions = ['.py']
abstract schema()[source]

Returns the schema for the arguments of this Template Resolver. This will be used to validate that the arguments passed in the stack config are what the Template Handler expects. :return: JSON schema that can be validated :rtype: object

standard_template_extensions = ['.json', '.yaml', '.template']
supported_template_extensions = ['.json', '.yaml', '.template', '.j2', '.py']
validate()[source]

Validates if the current arguments are correct according to the schema. If this does not raise an exception, the template handler’s arguments are valid.

Submodules

sceptre.template_handlers.file module

class sceptre.template_handlers.file.File(*args, **kwargs)[source]

Bases: sceptre.template_handlers.TemplateHandler

Template handler that can load files from disk. Supports JSON, YAML, Jinja2 and Python.

handle()[source]

An abstract method which must be overwritten by all inheriting classes. This method is called to retrieve the template. Implementation of this method in subclasses must return a string that can be interpreted by Sceptre (CloudFormation YAML / JSON, Jinja or Python)

schema()[source]

Returns the schema for the arguments of this Template Resolver. This will be used to validate that the arguments passed in the stack config are what the Template Handler expects. :return: JSON schema that can be validated :rtype: object

sceptre.template_handlers.helper module

sceptre.template_handlers.helper.call_sceptre_handler(path, sceptre_user_data)[source]

Calls the function sceptre_handler within templates that are python scripts.

Parameters
  • path – A path to the file.

  • sceptre_user_data – The sceptre_user_data parameter values.

Returns

The string returned from sceptre_handler in the template.

Return type

str

Raises

IOError

Raises

TemplateSceptreHandlerError

sceptre.template_handlers.helper.logger = <Logger sceptre.template_handlers.helper (WARNING)>

Template handler helpers.

sceptre.template_handlers.helper.print_template_traceback(path)[source]

Prints a stack trace, including only files which are inside a ‘templates’ directory. The function is intended to give the operator instant feedback about why their templates are failing to compile.

Parameters

path – A path to the file.

Return type

None

sceptre.template_handlers.helper.render_jinja_template(path, jinja_vars, j2_environment)[source]

Renders a jinja template.

Sceptre supports passing sceptre_user_data to JSON and YAML CloudFormation templates using Jinja2 templating.

Parameters
  • path (str) – The path to the template file.

  • jinja_vars (dict) – Dict of variables to render into the template.

  • j2_environment – The jinja2 environment.

Returns

The body of the CloudFormation template.

Return type

str

sceptre.template_handlers.http module

class sceptre.template_handlers.http.Http(*args, **kwargs)[source]

Bases: sceptre.template_handlers.TemplateHandler

Template handler that can resolve templates from the web. Standard CFN templates with extension (.json, .yaml, .template) are deployed directly from memory while references to jinja (.j2) and python (.py) templates are downloaded, transformed into CFN templates then deployed to AWS.

handle()[source]

handle template from web

schema()[source]

Returns the schema for the arguments of this Template Resolver. This will be used to validate that the arguments passed in the stack config are what the Template Handler expects. :return: JSON schema that can be validated :rtype: object

sceptre.template_handlers.s3 module

class sceptre.template_handlers.s3.S3(*args, **kwargs)[source]

Bases: sceptre.template_handlers.TemplateHandler

Template handler that can resolve templates from S3. Raw CFN templates with extension (.json, .yaml, .template) are deployed directly from memory while references to jinja (.j2) and python (.py) templates are downloaded, transformed into CFN templates then deployed to AWS.

handle()[source]

handle template in S3 bucket

schema()[source]

Returns the schema for the arguments of this Template Resolver. This will be used to validate that the arguments passed in the stack config are what the Template Handler expects. :return: JSON schema that can be validated :rtype: object