sceptre.plan package

class sceptre.plan.NullHandler(level=0)[source]

Bases: Handler

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

Submodules

sceptre.plan.actions module

sceptre.plan.actions

This module implements the StackActions class which provides the functionality available to a Stack.

class sceptre.plan.actions.StackActions(stack)[source]

Bases: object

StackActions stores the operations a Stack can take, such as creating or deleting the Stack.

Parameters

stack (sceptre.stack.Stack) – A Stack object

cancel_stack_update()[source]

Cancels a Stack update.

Returns

The cancelled Stack status.

Return type

sceptre.stack_status.StackStatus

change_set_creation_failed_due_to_no_changes(reason)[source]

Indicates the change set failed when it was created because there were actually no changes introduced from the change set.

Parameters

reason (str) – The reason reported by CloudFormation for the Change Set failure

Return type

bool

continue_update_rollback()[source]

Rolls back a Stack in the UPDATE_ROLLBACK_FAILED state to UPDATE_ROLLBACK_COMPLETE.

create()[source]

Creates a Stack.

Returns

The Stack’s status.

Return type

sceptre.stack_status.StackStatus

create_change_set(change_set_name)[source]

Creates a Change Set with the name change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

delete()[source]

Deletes the Stack.

Returns

The Stack’s status.

Return type

sceptre.stack_status.StackStatus

delete_change_set(change_set_name)[source]

Deletes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

describe()[source]

Returns the a description of the Stack.

Returns

A Stack description.

Return type

dict

describe_change_set(change_set_name)[source]

Describes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

The description of the Change Set.

Return type

dict

describe_events()[source]

Returns the CloudFormation events for a Stack.

Returns

CloudFormation events for a Stack.

Return type

dict

describe_outputs()[source]

Returns the Stack’s outputs.

Returns

The Stack’s outputs.

Return type

list

describe_resources()[source]

Returns the logical and physical resource IDs of the Stack’s resources.

Returns

Information about the Stack’s resources.

Return type

dict

diff(stack_differ)[source]

Returns a diff of local and deployed template and stack configuration using a specific diff library.

Parameters

stack_differ (StackDiffer) – The differ to use

Return type

StackDiff

Returns

A StackDiff object with the full, computed diff

drift_detect()[source]

Show stack drift for a running stack.

Return type

Dict[str, str]

Returns

The stack drift detection status. If the stack does not exist, we return a detection and stack drift status of STACK_DOES_NOT_EXIST. If drift detection times out after 5 minutes, we return TIMED_OUT.

drift_show(drifted=False)[source]

Detect drift status on stacks.

Parameters

drifted (bool) – Filter out IN_SYNC resources.

Return type

Tuple[str, dict]

Returns

The detection status and resource drifts.

dump_config()[source]

Dump the config for a stack.

dump_template()[source]

Dump the template for the Stack. An alias for generate for historical reasons.

estimate_cost()[source]

Estimates a Stack’s cost.

Returns

An estimate of the Stack’s cost.

Return type

dict

Raises

botocore.exceptions.ClientError

execute_change_set(change_set_name)[source]

Executes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

The Stack status

Return type

str

fetch_local_template_summary()[source]
fetch_remote_template()[source]

Returns the Template for the remote Stack

Return type

Optional[str]

Returns

the template body.

fetch_remote_template_summary()[source]
generate()[source]

Returns the Template for the Stack. An alias for dump_template for historical reasons.

get_policy()[source]

Returns a Stack’s Policy.

Returns

The Stack’s Stack Policy.

Return type

str

get_status()[source]

Returns the Stack’s status.

Returns

The Stack’s status.

Return type

sceptre.stack_status.StackStatus

launch()[source]

Launches the Stack.

If the Stack status is create_failed or rollback_complete, the Stack is deleted. Launch then tries to create or update the Stack, depending if it already exists. If there are no updates to be performed, launch exits gracefully.

Return type

StackStatus

Returns

The Stack’s status.

list_change_sets(url=False)[source]

Lists the Stack’s Change Sets.

Parameters

url (bool) – Write out a console URL instead.

Returns

The Stack’s Change Sets.

Return type

dict or list

lock()[source]

Locks the Stack by applying a deny-all updates Stack Policy.

set_policy(policy_path)[source]

Applies a Stack Policy.

Parameters

policy_path (str) – The relative path of JSON file containing the AWS Policy to apply.

unlock()[source]

Unlocks the Stack by applying an allow-all updates Stack Policy.

update()[source]

Updates the Stack.

Returns

The Stack’s status.

Return type

sceptre.stack_status.StackStatus

validate()[source]

Validates the Stack’s CloudFormation Template.

Raises an error if the Template is invalid.

Returns

Validation information about the Template.

Return type

dict

Raises

botocore.exceptions.ClientError

wait_for_cs_completion(change_set_name)[source]

Waits while the Stack Change Set status is “pending”.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

The Change Set’s status.

Return type

sceptre.stack_status.StackChangeSetStatus

sceptre.plan.executor module

sceptre.plan.executor

This module implements a SceptrePlanExecutor, which is responsible for executing the command specified in a SceptrePlan.

class sceptre.plan.executor.SceptrePlanExecutor(command, launch_order)[source]

Bases: object

execute(*args)[source]

Execute is responsible executing the sets of Stacks in launch_order concurrently, in the correct order.

Parameters

args – Any arguments that should be passed through to the StackAction being called.

sceptre.plan.plan module

sceptre.plan.plan

This module implements a SceptrePlan, which is responsible for holding all nessessary information for a command to execute.

class sceptre.plan.plan.SceptrePlan(context)[source]

Bases: object

cancel_stack_update(*args)[source]

Cancels a Stack update.

Returns

A dictionary of Stacks and their cancelled statuses.

Return type

dict

continue_update_rollback(*args)[source]

Rolls back a Stack in the UPDATE_ROLLBACK_FAILED state to UPDATE_ROLLBACK_COMPLETE.

Returns

A dictionary of Stacks

Return type

dict

create(*args)[source]

Creates the Stack.

Returns

A dictionary of Stacks and their status.

Return type

dict

create_change_set(*args)[source]

Creates a Change Set with the name change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

A dictionary of Stacks

Return type

dict

delete(*args)[source]

Deletes the Stack.

Returns

A dictionary of Stacks and their status.

Return type

dict

delete_change_set(*args)[source]

Deletes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

A dictionary of Stacks

Return type

dict

describe(*args)[source]

Returns the a description of the Stack.

Returns

A dictionary of Stacks and their description.

Return type

dict

describe_change_set(*args)[source]

Describes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

A dictionary of Stacks and their Change Set description.

Return type

dict

describe_events(*args)[source]

Returns a dictionary contianing the Stack events.

Returns

A dictionary of Stacks and their CloudFormation events.

Return type

dict

describe_outputs(*args)[source]

Returns a list of Stack outputs.

Returns

A dictionary of Stacks and their outputs.

Return type

dict

describe_resources(*args)[source]

Returns the logical and physical resource IDs of the Stack’s resources.

Returns

A dictionary of Stacks and their resources.

Return type

dict

diff(*args)[source]

Show diffs between the running and generated stack.

Return type

Dict[Stack, StackDiff]

Returns

A dict where the keys are Stack objects and the values are StackDiffs.

drift_detect(*args)[source]

Show drift detection status of a stack.

Return type

Dict[Stack, str]

Returns

A list of detected drift against running stacks.

drift_show(*args)[source]

Show stack drift for a running stack.

Return type

Dict[Stack, str]

Returns

A list of detected drift against running stacks.

dump_config(*args)[source]

Dump the config for a stack.

dump_template(*args)[source]

Dump the template for a stack. An alias for generate for historical reasons.

estimate_cost(*args)[source]

Estimates a Stack’s cost.

Returns

A dictionary of Stacks and their estimated costs.

Return type

dict

Raises

botocore.exceptions.ClientError

execute_change_set(*args)[source]

Executes the Change Set change_set_name.

Parameters

change_set_name (str) – The name of the Change Set.

Returns

A dictionary of Stacks and their status.

Return type

dict

fetch_remote_template(*args)[source]

Returns a generated Template for a given Stack

Returns

A list of Stacks and their template body.

Return type

List[str]

filter(predicate)[source]

Filters the plan’s resolved launch_order to remove specific stacks.

Parameters

predicate (Callable[[Stack], bool]) – This callable should take a single Stack and return True if it should stay in the launch_order or False if it should be filtered out.

generate(*args)[source]

Returns a generated Template for a given Stack. An alias for dump_template for historical reasons.

Returns

A dictionary of Stacks and their template body.

Return type

dict

get_policy(*args)[source]

Returns a Stack’s policy.

Returns

A dictionary of Stacks and their Stack policy.

Return type

dict

get_status(*args)[source]

Returns the Stack’s status.

Returns

A dictionary of Stacks and their status.

Return type

dict

Raises

sceptre.exceptions.StackDoesNotExistError

launch(*args)[source]

Launches the Stack.

If the Stack status is create_failed or rollback_complete, the Stack is deleted. Launch then tries to create or update the Stack, depending if it already exists. If there are no updates to be performed, launch exits gracefully.

Returns

A dictionary of Stacks and their status.

Return type

dict

list_change_sets(*args)[source]

Lists the Stack’s Change Sets.

Returns

TA dictionary of Stacks and their Change Sets.

Return type

dict

lock(*args)[source]

Locks the Stack by applying a deny all updates Stack policy.

Returns

A dictionary of Stacks

Return type

dict

remove_stack_from_plan(stack)[source]
resolve(command, reverse=False)[source]
set_policy(*args)[source]

Applies a Stack policy.

Parameters

policy_path (str) – the path of json file containing a aws policy

Returns

A dictionary of Stacks

Return type

dict

template(*args)[source]

Returns the CloudFormation Template used to create the Stack.

Returns

A dictionary of Stacks and their templates.

Return type

dict

unlock(*args)[source]

Unlocks the Stack by applying an allow all updates Stack policy.

Returns

A dictionary of Stacks

Return type

dict

update(*args)[source]

Updates the Stack.

Returns

A dictionary of Stacks and their status.

Return type

dict

validate(*args)[source]

Validates the Stack’s CloudFormation template.

Raises an error if the Template is invalid.

Returns

A dictionary of Stacks and their template validation information.

Return type

dict

Raises

botocore.exceptions.ClientError

wait_for_cs_completion(*args)[source]

Waits while the Stack Change Set status is “pending”.

Parameters

change_set_name (str) – The name of the Change Set.

Return type

dict

Return type

sceptre.stack_status.StackChangeSetStatus

sceptre.plan.plan.require_resolved(func)[source]
Return type

Callable