Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resolve #1212] Conditional Stacks via "ignore" and "obsolete" #1229

Merged
merged 109 commits into from
Sep 16, 2022

Conversation

jfalkenstein
Copy link
Contributor

@jfalkenstein jfalkenstein commented May 28, 2022

This feature adds two new Stack configurations, a new option on launch and a new command (prune):

  • ignore will cause the launch command to completely ignore the Stack; It will be neither created, nor updated, nor deleted. If the Stack currently exists on AWS, it will stay as it is. If the stack does not exist on AWS, it will not be created.
  • obsolete stacks function like ignored. ones, but will be deleted when pruned (see below)
  • The launch command now has a --prune option. When launch --prune is invoked, all obsolete stacks on the command path will deleted first before the rest of the deployment proceeds.
  • The new prune command will delete all obsolete stacks in the entire project (irrespective of any command path). This is a simple way to clean up potentially multiple stacks that need to be deleted.

This PR adds the feature described in #1212 and addresses the spirit of #1193 .

The basic idea here is you could do something like:

template:
    path: my/test/resources.yaml

{% if not var.use_test_resources %}
# If we set obsolete: True, it won't be created and will be deleted if it exists when launched with --prune
obsolete: True
{% endif %}

This feature addresses two needs:

  1. The ability to selectively exclude Stack Configs when you run sceptre launch when it isn't ready or certain Jinja Logic determines that it should not be launched.
  2. The ability to delete stacks as a part of a CI/CD process when they aren't needed/wanted any more.

PR Checklist

  • Wrote a good commit message & description [see guide below].
  • Commit message starts with [Resolve #issue-number].
  • Added/Updated unit tests.
  • Added/Updated integration tests (if applicable).
  • All unit tests (make test) are passing.
  • Used the same coding conventions as the rest of the project.
  • The new code passes pre-commit validations (pre-commit run --all-files).
  • The PR relates to only one subject with a clear title.
    and description in grammatically correct, complete sentences.

Approver/Reviewer Checklist

  • Before merge squash related commits.

Other Information

Guide to writing a good commit

@jfalkenstein jfalkenstein self-assigned this May 28, 2022
@jfalkenstein jfalkenstein changed the title [Resolve #1212] Conditional Stacks [Resolve #1212] WIP Conditional Stacks May 28, 2022
@jfalkenstein jfalkenstein changed the title [Resolve #1212] WIP Conditional Stacks [Resolve #1212] Conditional Stacks vis launch_action configuration Jun 19, 2022
@jfalkenstein jfalkenstein marked this pull request as ready for review June 19, 2022 17:22
Copy link
Contributor

@zaro0508 zaro0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with this approach therefore I have left reviewing the details until we can flush it out a bit more.

docs/_source/docs/faq.rst Outdated Show resolved Hide resolved
docs/_source/docs/faq.rst Outdated Show resolved Hide resolved
docs/_source/docs/stack_config.rst Outdated Show resolved Hide resolved
docs/_source/docs/stack_config.rst Outdated Show resolved Hide resolved
docs/_source/docs/stack_config.rst Show resolved Hide resolved
docs/_source/docs/stack_config.rst Outdated Show resolved Hide resolved
integration-tests/steps/templates.py Show resolved Hide resolved
sceptre/plan/actions.py Outdated Show resolved Hide resolved
sceptre/plan/actions.py Outdated Show resolved Hide resolved
tests/test_stack.py Show resolved Hide resolved
sceptre/cli/launch.py Outdated Show resolved Hide resolved
docs/_source/docs/faq.rst Outdated Show resolved Hide resolved
@jfalkenstein jfalkenstein requested a review from zaro0508 August 14, 2022 14:39
Copy link
Contributor

@alex-harvey-z3q alex-harvey-z3q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfalkenstein approving on the basis that I don't have any objection to it and can't see any issue with it after reading your excellent docs and a once over read of the code without fully understanding it!

docs/_source/docs/faq.rst Outdated Show resolved Hide resolved
docs/_source/docs/faq.rst Show resolved Hide resolved
integration-tests/features/launch-stack.feature Outdated Show resolved Hide resolved
docs/_source/docs/stack_config.rst Show resolved Hide resolved
docs/_source/docs/stack_config.rst Show resolved Hide resolved
sceptre/cli/prune.py Show resolved Hide resolved
sceptre/stack.py Outdated Show resolved Hide resolved
sceptre/stack.py Outdated Show resolved Hide resolved
sceptre/cli/prune.py Show resolved Hide resolved
sceptre/cli/launch.py Show resolved Hide resolved
@jfalkenstein jfalkenstein requested a review from zaro0508 August 28, 2022 21:37
Copy link
Contributor

@zaro0508 zaro0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally LGTM, just one more minor request and i think we are good to go.

sceptre/stack.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants