stacker.actions package

Submodules

stacker.actions.base module

class stacker.actions.base.BaseAction(context, provider_builder=None, cancel=None)[source]

Bases: future.types.newobject.newobject

Actions perform the actual work of each Command.

Each action is tied to a stacker.commands.base.BaseCommand, and is responsible for building the stacker.plan.Plan that will be executed to perform that command.

Parameters:context (stacker.context.Context) – The stacker context for the current run.
:param provider_builder (stacker.providers.base.BaseProviderBuilder,: optional): An object that will build a provider that will be
interacted with in order to perform the necessary actions.
build_provider(stack)[source]

Builds a stacker.providers.base.Provider suitable for operating on the given stacker.Stack.

ensure_cfn_bucket()[source]

The CloudFormation bucket where templates will be stored.

execute(*args, **kwargs)[source]
post_run(*args, **kwargs)[source]
pre_run(*args, **kwargs)[source]
provider

Some actions need a generic provider using the default region (e.g. hooks).

run(*args, **kwargs)[source]
s3_stack_push(blueprint, force=False)[source]

Pushes the rendered blueprint’s template to S3.

Verifies that the template doesn’t already exist in S3 before pushing.

Returns the URL to the template in S3.

stack_template_url(blueprint)[source]
stacker.actions.base.build_walker(concurrency)[source]

This will return a function suitable for passing to stacker.plan.Plan for walking the graph.

If concurrency is 1 (no parallelism) this will return a simple topological walker that doesn’t use any multithreading.

If concurrency is 0, this will return a walker that will walk the graph as fast as the graph topology allows.

If concurrency is greater than 1, it will return a walker that will only execute a maximum of concurrency steps at any given time.

Returns:returns a function to walk a stacker.dag.DAG.
Return type:func
stacker.actions.base.plan(description, stack_action, context, tail=None, reverse=False)[source]

A simple helper that builds a graph based plan from a set of stacks.

Parameters:
  • description (str) – a description of the plan.
  • action (func) – a function to call for each stack.
  • context (stacker.context.Context) – a stacker.context.Context to build the plan from.
  • tail (func) – an optional function to call to tail the stack progress.
  • reverse (bool) – if True, execute the graph in reverse (useful for destroy actions).
Returns:

The resulting plan object

Return type:

plan.Plan

stacker.actions.base.stack_template_key_name(blueprint)[source]

Given a blueprint, produce an appropriate key name.

Parameters:blueprint (stacker.blueprints.base.Blueprint) – The blueprint object to create the key from.
Returns:Key name resulting from blueprint.
Return type:string
stacker.actions.base.stack_template_url(bucket_name, blueprint, endpoint)[source]

Produces an s3 url for a given blueprint.

Parameters:
  • bucket_name (string) – The name of the S3 bucket where the resulting templates are stored.
  • blueprint (stacker.blueprints.base.Blueprint) – The blueprint object to create the URL to.
  • endpoint (string) – The s3 endpoint used for the bucket.
Returns:

S3 URL.

Return type:

string

stacker.actions.build module

class stacker.actions.build.Action(context, provider_builder=None, cancel=None)[source]

Bases: stacker.actions.base.BaseAction

Responsible for building & coordinating CloudFormation stacks.

Generates the build plan based on stack dependencies (these dependencies are determined automatically based on output lookups from other stacks).

The plan can then either be printed out as an outline or executed. If executed, each stack will get launched in order which entails:

  • Pushing the generated CloudFormation template to S3 if it has changed
  • Submitting either a build or update of the given stack to the
    stacker.provider.base.Provider.
build_parameters(stack, provider_stack=None)[source]

Builds the CloudFormation Parameters for our stack.

Parameters:
  • stack (stacker.stack.Stack) – A stacker stack
  • provider_stack (dict) – An optional Stacker provider object
Returns:

The parameters for the given stack

Return type:

dict

post_run(outline=False, dump=False, *args, **kwargs)[source]

Any steps that need to be taken after running the action.

pre_run(outline=False, dump=False, *args, **kwargs)[source]

Any steps that need to be taken prior to running the action.

run(concurrency=0, outline=False, tail=False, dump=False, *args, **kwargs)[source]

Kicks off the build/update of the stacks in the stack_definitions.

This is the main entry point for the Builder.

class stacker.actions.build.UsePreviousParameterValue[source]

Bases: object

A simple class used to indicate a Parameter should use it’s existng value.

stacker.actions.build.build_stack_tags(stack)[source]

Builds a common set of tags to attach to a stack

stacker.actions.build.handle_hooks(stage, hooks, provider, context, dump, outline)[source]

Handle pre/post hooks.

Parameters:
  • stage (str) – The name of the hook stage - pre_build/post_build.
  • hooks (list) – A list of dictionaries containing the hooks to execute.
  • provider (stacker.provider.base.BaseProvider) – The provider the current stack is using.
  • context (stacker.context.Context) – The current stacker context.
  • dump (bool) – Whether running with dump set or not.
  • outline (bool) – Whether running with outline set or not.
stacker.actions.build.should_ensure_cfn_bucket(outline, dump)[source]

Test whether access to the cloudformation template bucket is required

Parameters:
  • outline (bool) – The outline action.
  • dump (bool) – The dump action.
Returns:

If access to CF bucket is needed, return True.

Return type:

bool

stacker.actions.build.should_submit(stack)[source]

Tests whether a stack should be submitted to CF for update/create

Parameters:stack (stacker.stack.Stack) – The stack object to check.
Returns:If the stack should be submitted, return True.
Return type:bool
stacker.actions.build.should_update(stack)[source]

Tests whether a stack should be submitted for updates to CF.

Parameters:stack (stacker.stack.Stack) – The stack object to check.
Returns:If the stack should be updated, return True.
Return type:bool

stacker.actions.destroy module

class stacker.actions.destroy.Action(context, provider_builder=None, cancel=None)[source]

Bases: stacker.actions.base.BaseAction

Responsible for destroying CloudFormation stacks.

Generates a destruction plan based on stack dependencies. Stack dependencies are reversed from the build action. For example, if a Stack B requires Stack A during build, during destroy Stack A requires Stack B be destroyed first.

The plan defaults to printing an outline of what will be destroyed. If forced to execute, each stack will get destroyed in order.

post_run(outline=False, *args, **kwargs)[source]

Any steps that need to be taken after running the action.

pre_run(outline=False, *args, **kwargs)[source]

Any steps that need to be taken prior to running the action.

run(force, concurrency=0, tail=False, *args, **kwargs)[source]

stacker.actions.diff module

class stacker.actions.diff.Action(context, provider_builder=None, cancel=None)[source]

Bases: stacker.actions.build.Action

Responsible for diff’ing CF stacks in AWS and on disk

Generates the build plan based on stack dependencies (these dependencies are determined automatically based on references to output values from other stacks).

The plan is then used to create a changeset for a stack using a generated template based on the current config.

post_run(*args, **kwargs)[source]

Any steps that need to be taken after running the action.

pre_run(*args, **kwargs)[source]

Any steps that need to be taken prior to running the action.

run(concurrency=0, *args, **kwargs)[source]

Kicks off the build/update of the stacks in the stack_definitions.

This is the main entry point for the Builder.

class stacker.actions.diff.DictValue(key, old_value, new_value)[source]

Bases: future.types.newobject.newobject

ADDED = 'ADDED'
MODIFIED = 'MODIFIED'
REMOVED = 'REMOVED'
UNMODIFIED = 'UNMODIFIED'
changes()[source]

Returns a list of changes to represent the diff between old and new value.

Returns:
[string] representation of the change (if any)
between old and new value
Return type:list
formatter = '%s%s = %s'
status()[source]
stacker.actions.diff.diff_dictionaries(old_dict, new_dict)[source]

Diffs two single dimension dictionaries

Returns the number of changes and an unordered list expressing the common entries and changes.

Parameters:
  • old_dict (dict) – old dictionary
  • new_dict (dict) – new dictionary
Returns: list()
int: number of changed records list: [DictValue]
stacker.actions.diff.diff_parameters(old_params, new_params)[source]

Compares the old vs. new parameters and returns a “diff”

If there are no changes, we return an empty list.

Parameters:
  • old_params (dict) – old paramters
  • new_params (dict) – new parameters
Returns:

A list of differences

Return type:

list

stacker.actions.diff.format_params_diff(parameter_diff)[source]

Handles the formatting of differences in parameters.

Parameters:parameter_diff (list) – A list of DictValues detailing the differences between two dicts returned by stacker.actions.diff.diff_dictionaries()
Returns:A formatted string that represents a parameter diff
Return type:string

stacker.actions.info module

class stacker.actions.info.Action(context, provider_builder=None, cancel=None)[source]

Bases: stacker.actions.base.BaseAction

Get information on CloudFormation stacks.

Displays the outputs for the set of CloudFormation stacks.

run(*args, **kwargs)[source]

Module contents