sceptre.diffing package¶
Submodules¶
sceptre.diffing.diff_writer module¶
- class sceptre.diffing.diff_writer.ColouredDiffLibWriter(stack_diff, output_stream, output_format)[source]¶
Bases:
DiffLibWriter
A DiffWriter for StackDiffs where the DiffType is a a list of strings with coloured diffs.
- class sceptre.diffing.diff_writer.DeepDiffWriter(stack_diff, output_stream, output_format)[source]¶
Bases:
DiffWriter
[DeepDiff
]A DiffWriter for StackDiffs where the DiffType is a DeepDiff object.
- class sceptre.diffing.diff_writer.DiffLibWriter(stack_diff, output_stream, output_format)[source]¶
Bases:
DiffWriter
[List
[str
]]A DiffWriter for StackDiffs where the DiffType is a a list of strings.
- class sceptre.diffing.diff_writer.DiffWriter(stack_diff, output_stream, output_format)[source]¶
Bases:
Generic
[DiffType
]A component responsible for taking a StackDiff and writing it in a way that is useful and readable. This is an abstract base class, so the abstract methods need to be implemented to create a DiffWriter for a given DiffType.
- LINE_BAR = '--------------------------------------------------------------------------------'¶
- STAR_BAR = '********************************************************************************'¶
- abstract dump_diff(diff)[source]¶
“Implement this method to write the DiffType to string
- Return type
- abstract property has_config_difference: bool¶
Implement this to indicate whether or not there is a config difference
- Return type
sceptre.diffing.stack_differ module¶
- class sceptre.diffing.stack_differ.DeepDiffStackDiffer(show_no_echo=False, *, universal_template_loader=<function load>)[source]¶
Bases:
StackDiffer
[DeepDiff
]A StackDiffer that relies upon the DeepDiff library to produce the difference between the stack as it has been deployed onto CloudFormation and as it exists locally within Sceptre.
This differ relies upon a recursive key/value comparison of Python data structures, indicating specific keys or values that have been added, removed, or altered between the two. Templates are read in as dictionaries and compared this way, so json or yaml formatting changes will not be reflected, only changes in value.
- VERBOSITY_LEVEL_TO_INDICATE_CHANGED_VALUES = 2¶
- compare_stack_configurations(deployed, generated)[source]¶
Implement this method to return the diff for the stack configurations.
- Parameters
deployed (
Optional
[StackConfiguration
]) – The StackConfiguration as it has been deployed. This MIGHT be None, if the stack has not been deployed.generated (
StackConfiguration
) – The StackConfiguration as it exists locally within Sceptre
- Return type
- Returns
The generated diff between the two
- class sceptre.diffing.stack_differ.DifflibStackDiffer(show_no_echo=False, *, universal_template_loader=<function load>)[source]¶
Bases:
StackDiffer
[List
[str
]]A StackDiffer that uses difflib to produce a diff between the stack as it exists on AWS and the stack as it exists locally within Sceptre.
Because difflib generates diffs off of lists of strings, both StackConfigurations and
- compare_stack_configurations(deployed, generated)[source]¶
Implement this method to return the diff for the stack configurations.
- Parameters
deployed (
Optional
[StackConfiguration
]) – The StackConfiguration as it has been deployed. This MIGHT be None, if the stack has not been deployed.generated (
StackConfiguration
) – The StackConfiguration as it exists locally within Sceptre
- Return type
- Returns
The generated diff between the two
- class sceptre.diffing.stack_differ.StackConfiguration(stack_name: str, parameters: Dict[str, Union[str, List[str]]], stack_tags: Dict[str, str], notifications: List[str], cloudformation_service_role: Optional[str])[source]¶
Bases:
NamedTuple
A data container to represent the comparable parts of a Stack.
- class sceptre.diffing.stack_differ.StackDiff(stack_name: str, template_diff: DiffType, config_diff: DiffType, is_deployed: bool, generated_config: StackConfiguration, generated_template: str)[source]¶
Bases:
NamedTuple
A data container to represent the full difference between a deployed stack and the stack as it exists locally within Sceptre.
- config_diff: DiffType¶
Alias for field number 2
- generated_config: StackConfiguration¶
Alias for field number 4
- template_diff: DiffType¶
Alias for field number 1
- class sceptre.diffing.stack_differ.StackDiffer(show_no_echo=False)[source]¶
Bases:
Generic
[DiffType
]A utility for producing a StackDiff that indicates the full difference between a given stack as it is currently DEPLOYED on CloudFormation and the stack as it exists in the local Sceptre configurations.
This utility compares both the stack configuration (specifically those attributes that CAN be compared) as well as the stack template.
As an abstract base class, the two comparison methods need to be implemented so that the StackDiff can be generated.
- NO_ECHO_REPLACEMENT = '***HIDDEN***'¶
- STACK_STATUSES_INDICATING_NOT_DEPLOYED = ['CREATE_FAILED', 'ROLLBACK_COMPLETE', 'DELETE_COMPLETE']¶
- abstract compare_stack_configurations(deployed, generated)[source]¶
Implement this method to return the diff for the stack configurations.
- Parameters
deployed (
Optional
[StackConfiguration
]) – The StackConfiguration as it has been deployed. This MIGHT be None, if the stack has not been deployed.generated (
StackConfiguration
) – The StackConfiguration as it exists locally within Sceptre
- Return type
TypeVar
(DiffType
)- Returns
The generated diff between the two
- abstract compare_templates(deployed, generated)[source]¶
Implement this method to return the diff for the templates
- diff(stack_actions)[source]¶
Produces a StackDiff between the currently deployed stack (if it exists) and the stack as it exists locally in Sceptre.
- Parameters
stack_actions (
StackActions
) – The StackActions object to use for generating and fetching templates as well as providing other details about the stack.- Return type
- Returns
The StackDiff that expresses the difference.
- sceptre.diffing.stack_differ.repr_odict(dumper, data)[source]¶
A YAML Representer for cfn-flip’s ODict objects.
ODicts are a variation on OrderedDicts for that library. Since the Diff command makes extensive use of ODicts, they can end up in diff output and the PyYaml library doesn’t otherwise calls the dicts like !!ODict, which looks weird. We can just treat them like normal dicts when we serialize them, though.
- Parameters
dumper (
Dumper
) – The Dumper that is being used to serialize this objectdata (
ODict
) – The ODict object to serialize
- Return type
- Returns
The serialized ODict