sceptre.cli package

sceptre.cli

This module implements Sceptre’s CLI, and should not be directly imported.

Submodules

sceptre.cli.create module

sceptre.cli.delete module

sceptre.cli.diff module

sceptre.cli.diff.filter_plan_for_launchable(plan)[source]
sceptre.cli.diff.output_buffer_with_normalized_bar_lengths(buffer, output_stream)[source]

Takes the output from a buffer and ensures that the star and line bars are the same length across the entire buffer and that their length is the full width of longest line.

Parameters
  • buffer (StringIO) – The input stream to normalize bar lengths for

  • output_stream (TextIO) – The stream to output the normalized buffer into

sceptre.cli.diff.output_diffs(diffs, writer_class, output_buffer, output_format)[source]

Outputs the diff results to the output_buffer.

Parameters
  • diffs (Iterable[StackDiff]) – The differences computed

  • writer_class (Type[DiffWriter]) – The DiffWriter class to be instantiated for each StackDiff

  • output_buffer (TextIO) – The buffer to write the diff results to

  • output_format (str) – The format to output the results in

Return type

int

Returns

The number of stacks that had a difference

sceptre.cli.describe module

sceptre.cli.execute module

sceptre.cli.helpers module

class sceptre.cli.helpers.CfnYamlLoader(stream)[source]

Bases: SafeLoader

yaml_multi_constructors = {'!': <function _tag_constructor>}
class sceptre.cli.helpers.ColouredFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

ColouredFormatter add colours to all stack statuses that appear in log messages.

format(record)[source]

Colours and returns all stack statuses in record.

Parameters

record (str) – The log item to format.

Returns

str

stack_status_colourer = <sceptre.stack_status_colourer.StackStatusColourer object>
class sceptre.cli.helpers.CustomJsonEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

CustomJsonEncoder is a JSONEncoder which encodes all items as JSON by calling their __str__() method.

default(item)[source]

Returns stringified version of item.

Parameters

item (object) – An arbitrary object to stringify.

Returns

The stringified object.

Return type

str

sceptre.cli.helpers.catch_exceptions(func)[source]

Catches and simplifies expected errors thrown by sceptre.

catch_exceptions should be used as a decorator.

Parameters

func – The function which may throw exceptions which should be simplified.

Returns

The decorated function.

sceptre.cli.helpers.confirmation(command, ignore, command_path, change_set=None)[source]
sceptre.cli.helpers.deserialize_json_properties(value)[source]
sceptre.cli.helpers.setup_logging(debug, no_colour)[source]

Sets up logging.

By default, the python logging module is configured to push logs to stdout as long as their level is at least INFO. The log format is set to “[%(asctime)s] - %(name)s - %(message)s” and the date format is set to “%Y-%m-%d %H:%M:%S”.

After this function has run, modules should:

import logging

logging.getLogger(__name__).info("my log message")
Parameters

debug (bool) – A flag indication whether to turn on debug logging.

No_colour

A flag to indicating whether to turn off coloured output.

Returns

A logger.

Return type

logging.Logger

sceptre.cli.helpers.setup_vars(var_file, var, merge_vars, debug, no_colour)[source]

Handle –var-file and –var arguments before returning data for the user_variables as required by the ConfigReader and SceptreContext.

Parameters
  • var_file (List[Dict]) – the var_file list.

  • var (List[str]) – the var list.

  • merge_vars (bool) – Merge instead of overwrite duplicate keys.

  • debug (bool) – debug mode.

  • no_colour (bool) – no_colour mode.

Returns

data for the user_variables.

Return type

Dict

sceptre.cli.helpers.simplify_change_set_description(response)[source]

Simplies the response from the AWS describe change set API.

Parameters

response (dict) – The original api response.

Returns

A more concise description of the change set.

Return type

dict

sceptre.cli.helpers.stack_status_exit_code(statuses)[source]
sceptre.cli.helpers.write(var, output_format='json', no_colour=True, file_path=None)[source]

Writes var to stdout. If output_format is set to “json” or “yaml”, write var as a JSON or YAML string.

Parameters
  • var (Any) – The object to print

  • output_format (str) – The format to print the output as. Allowed values: “text”, “json”, “yaml”

  • no_colour (bool) – Whether to colour stack statuses

  • file_path (Optional[Path]) – Optional path to a file to save the output

Return type

None

sceptre.cli.launch module

class sceptre.cli.launch.Launcher(context, plan_factory=<class 'sceptre.plan.plan.SceptrePlan'>, pruner_factory=<class 'sceptre.cli.prune.Pruner'>)[source]

Bases: object

Launcher is a utility to coordinate the flow of launching.

Parameters
  • context (SceptreContext) – The Sceptre context to use for launching

  • plan_factory – A callable with the signature of (SceptreContext) -> SceptrePlan

confirm(prune)[source]
launch(prune)[source]
Return type

int

print_operations(prune)[source]

sceptre.cli.list module

sceptre.cli.list.write_outputs(export, responses, plan, context)[source]

Helper function for list outputs.

sceptre.cli.new module

sceptre.cli.policy module

sceptre.cli.status module

sceptre.cli.template module

sceptre.cli.update module