-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add sam delete command #3176
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5eddc44
feat: Delete methods for CF stacks and S3 files (#2981)
hnnasit 524d90a
Delete template artifacts (#3022)
hnnasit 0016b18
Get s3 info cf template (#3050)
hnnasit 57f4289
Sam delete integration testing (#3076)
hnnasit dca984d
Auto ECR Companion Stack Deletion (#3080)
hnnasit fd4f771
Sam delete bug fixes (#3122)
hnnasit 16fb3fa
Merge remote-tracking branch 'aws-sam-cli-public/feat/sam_delete_deve…
moelasmar 830f465
add sam delete to pyinstaller hooks file
moelasmar 86bc4ca
fix typo
moelasmar 936744c
resolve pr comments
moelasmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """ | ||
| `sam delete` command | ||
| """ | ||
|
|
||
| # Expose the cli object here | ||
| from .command import cli # noqa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| """ | ||
| CLI command for "delete" command | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| import click | ||
| from samcli.cli.main import aws_creds_options, common_options, pass_context, print_cmdline_args | ||
|
|
||
| from samcli.lib.utils.version_checker import check_newer_version | ||
|
|
||
| SHORT_HELP = "Delete an AWS SAM application and the artifacts created by sam deploy." | ||
|
|
||
| HELP_TEXT = """The sam delete command deletes the CloudFormation | ||
| stack and all the artifacts which were created using sam deploy. | ||
|
|
||
| \b | ||
| e.g. sam delete | ||
|
|
||
| \b | ||
| """ | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @click.command( | ||
| "delete", | ||
| short_help=SHORT_HELP, | ||
| context_settings={"ignore_unknown_options": False, "allow_interspersed_args": True, "allow_extra_args": True}, | ||
| help=HELP_TEXT, | ||
| ) | ||
| @click.option( | ||
| "--stack-name", | ||
| required=False, | ||
| help="The name of the AWS CloudFormation stack you want to delete. ", | ||
| ) | ||
| @click.option( | ||
| "--config-file", | ||
| help=( | ||
| "The path and file name of the configuration file containing default parameter values to use. " | ||
| "Its default value is 'samconfig.toml' in project directory. For more information about configuration files, " | ||
| "see: " | ||
| "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html." | ||
| ), | ||
| type=click.STRING, | ||
| default="samconfig.toml", | ||
| show_default=True, | ||
| ) | ||
| @click.option( | ||
| "--config-env", | ||
| help=( | ||
| "The environment name specifying the default parameter values in the configuration file to use. " | ||
| "Its default value is 'default'. For more information about configuration files, see: " | ||
| "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html." | ||
| ), | ||
| type=click.STRING, | ||
| default="default", | ||
| show_default=True, | ||
| ) | ||
| @click.option( | ||
| "--no-prompts", | ||
| help=("Specify this flag to allow SAM CLI to skip through the guided prompts."), | ||
| is_flag=True, | ||
| required=False, | ||
| ) | ||
| @aws_creds_options | ||
| @common_options | ||
| @pass_context | ||
| @check_newer_version | ||
| @print_cmdline_args | ||
| def cli(ctx, stack_name: str, config_file: str, config_env: str, no_prompts: bool): | ||
| """ | ||
| `sam delete` command entry point | ||
| """ | ||
|
|
||
| # All logic must be implemented in the ``do_cli`` method. This helps with easy unit testing | ||
| do_cli( | ||
| stack_name=stack_name, | ||
| region=ctx.region, | ||
| config_file=config_file, | ||
| config_env=config_env, | ||
| profile=ctx.profile, | ||
| no_prompts=no_prompts, | ||
| ) # pragma: no cover | ||
|
|
||
|
|
||
| def do_cli(stack_name: str, region: str, config_file: str, config_env: str, profile: str, no_prompts: bool): | ||
| """ | ||
| Implementation of the ``cli`` method | ||
| """ | ||
| from samcli.commands.delete.delete_context import DeleteContext | ||
|
|
||
| with DeleteContext( | ||
| stack_name=stack_name, | ||
| region=region, | ||
| profile=profile, | ||
| config_file=config_file, | ||
| config_env=config_env, | ||
| no_prompts=no_prompts, | ||
| ) as delete_context: | ||
| delete_context.run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.