Skip to content

Commit

Permalink
Sam delete develop merged (#3176)
Browse files Browse the repository at this point in the history
* feat: Delete methods for CF stacks and S3 files (#2981)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* Fixed lint errors and added few unit tests

* Make black happy

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Updated code based on Chris' comments

* Small changes and fixes based on the comments

* Removed region prompt

* Update SAM context values for profile and region in delete_context.py

* Added typing for get_cf_template_name method

* Added stack_name prompt if the stack_name is not present in samconfig file

* Replace [] with get() for stack-name in delete_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Delete template artifacts (#3022)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Get s3 info cf template (#3050)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Sam delete integration testing (#3076)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Init integration tests methods for sam delete

* Added more template files as a list for sam delete integration testing

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Added 2 more integrations tests no_stack_deployed and delete for image type resources

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Added few more integration tests for delete

* Merged delete-template-artifacts branch code and updated this branch code

* Added tests for no prefix present for zip and image

* Added a check to confirm input stack is deleted for all the integration tests

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

* Added integration test for deleting nested stacks

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Auto ECR Companion Stack Deletion (#3080)

* Added ecr_bootstrap

* Added companion_stack_manager

* Added Companion Stack Manager

* Added update_companion_stack

* Updated companion_stack_builder File Name

* Formatted with Black

* Updated get_unreferenced_repos

* Updated guided_context to Use Companion Stack

* Added Delete Auto Create ECR Repo Prompt

* Updated prompt_image_repository Flow

* Added --resolve-image-repos

* Addressed Some of Pylint Issues

* Updated Helper Text

* Updated Comments

* Fixed Typing

* Removed Unused Imports

* Updated Unit Tests

* Updated UX and Fixed Windows ANSI

* Updated Unit Tests

* Fixed Import Order

* Added Ignore Import Check

* Added Integration Tests

* Updated help text.

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Added Comments for Name Generation

* Updated Image Option Validator

* Updated CompanionStackBuilder to Use Dict instead of String

* Fixed Argument Ordering

* Added Mapping Information to Help Text

* Updated delete_unreferenced_repos Doc String

* Updated sync_repos Doc String

* Added Justification for ECR Repo Physical ID

* Refactored to be Less Coupled

* Refactored for prompt_specify_repos

* Fixed Unit Test

* Moved WaiterConfig Out of Methods

* Updated Typing

* Updated Managed S3 Template to be Dict

* Fixed Typo

* Added Comments for _save_image_repositories

* Fixed Pylint Issue

* Added Missing Check for unreferenced_repo_uris

* Updated Variable Name

* Fixed Typo

* Updated Windows Check to Use platform.system()

* Updated update_companion_stack Logic

* Fixed Comment Typo

* Fixed Typos

* Fixed Test Name

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* fix: pass copy of environment variables for keeping cache valid (#2943)

* fix: pass copy of environment variables for keeping cache valid

* add integ tests

* update docs

* make black happy

Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* fix: Skip build of Docker image if ImageUri is a valid ECR URL (#2934) (#2935)

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Add condition to managed bucket policy (#2999)

* Removed region prompt

* Update appveyor.yml to do docker login on both dockerhub and Public ECR (#3005) (#3006)

Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>

* chore: bump version to 1.25.0 (#3007)

Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* temp: reduce python testing matrix (#3008)

* temp: disable testing against python 3.8, and enabled 3.7 (#3009)

* temp: disable testing against python 3.8, and enabled 3.7

* temp: disable testing against python 3.8, and enabled 3.7 & 3.6

* fix: enable all runtimes in python testing matrix (#3011)

* revert: enable all runtimes in python testing matrix

* fix indentation for yml

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* chore: update to aws-sam-translator 1.37.0 (#3019)

* chore: bump version to 1.26.0 (#3020)

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* chore: Improved --resolve-s3 option documentation and deployment without s3 error messages (#2983)

* Improve documentation on --resolve-s3 option and improve s3 failure messages

* Changed indentation for integration test on s3 error message

* Fixed a typo in description

* Improve spacing on help text for resolve-s3 option

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

* Defined UI for auto ecr deleton and method calls from companion_stack_manager

* Added code for deleting repos from companion stack

* Handle json templates deployed to cf

* Changed the order of companion stack and ecr repos deletion

* Handle delete_failed status for ecr companion stack and changed delete_stack to include retain_resources

* Reformatted auto ecr deletion to handle deleting companion stack as input stack name

* Fixed and added more unit tests for delete_context

* When region is not provided, prompt user to enter profile and region

* Removed region prompt and reading it from current session or assign a default instead

* Added ECR resource in packageable_resources and refactored ecr companion stack deletion

* Added log statements and unit tests for ECRResource

* Better error handling for ecr delete_artifact

* Revert "Merge remote-tracking branch 'wiltons-repo/feat/auto-ecr' into auto-ecr-delete"

This reverts commit 0e159c2, reversing
changes made to 1675b7e.

* Added unit test for delete ecr repository

* Fixed small string nits and added docstring for ECRResource

* Added some unit tests for s3_uploader, ecr_uploader and delete_context

* Updated to context refresh only when region and profile have non None values and removed unused class variable in delete_context

* Added unit test for ResourceImageDict class methods

Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* Sam delete bug fixes (#3122)

* Fixed small bugs for no_prompts and for deleting artifacts

* Updated integration tests and added test for termination protection for sam delete

* Added few more integration tests for guided and non-guided delete

* Updated handling termination protection and changed the order of deleting artifacts and stack

* Added comments for delete artifacts to handle intrinsic ref functions and handled this for image resources

* Added integration test for retaining s3 artifact

* Changed option_name to the correct values in delete_context

* Small UX fix and updated delete_prefix_artifacts method prefix to fetch S3 files

* Added a note in s3_uploader.py about using the api list_objects_v2

* add sam delete to pyinstaller hooks file

* fix typo

* resolve pr comments

Co-authored-by: hnnasit <84355507+hnnasit@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>
  • Loading branch information
10 people committed Aug 17, 2021
1 parent 6e6aed6 commit bfbcc16
Show file tree
Hide file tree
Showing 31 changed files with 2,850 additions and 85 deletions.
1 change: 1 addition & 0 deletions installer/pyinstaller/hook-samcli.py
Expand Up @@ -13,6 +13,7 @@
"samcli.commands.deploy",
"samcli.commands.logs",
"samcli.commands.publish",
"samcli.commands.delete",
"samcli.commands.pipeline.pipeline",
"samcli.commands.pipeline.init",
"samcli.commands.pipeline.bootstrap",
Expand Down
13 changes: 9 additions & 4 deletions samcli/cli/cli_config_file.py
Expand Up @@ -27,12 +27,14 @@ class TomlProvider:
A parser for toml configuration files
"""

def __init__(self, section=None):
def __init__(self, section=None, cmd_names=None):
"""
The constructor for TomlProvider class
:param section: section defined in the configuration file nested within `cmd`
:param cmd_names: cmd_name defined in the configuration file
"""
self.section = section
self.cmd_names = cmd_names

def __call__(self, config_path, config_env, cmd_names):
"""
Expand Down Expand Up @@ -67,18 +69,21 @@ def __call__(self, config_path, config_env, cmd_names):
LOG.debug("Config file '%s' does not exist", samconfig.path())
return resolved_config

if not self.cmd_names:
self.cmd_names = cmd_names

try:
LOG.debug(
"Loading configuration values from [%s.%s.%s] (env.command_name.section) in config file at '%s'...",
config_env,
cmd_names,
self.cmd_names,
self.section,
samconfig.path(),
)

# NOTE(TheSriram): change from tomlkit table type to normal dictionary,
# so that click defaults work out of the box.
resolved_config = dict(samconfig.get_all(cmd_names, self.section, env=config_env).items())
resolved_config = dict(samconfig.get_all(self.cmd_names, self.section, env=config_env).items())
LOG.debug("Configuration values successfully loaded.")
LOG.debug("Configuration values are: %s", resolved_config)

Expand All @@ -87,7 +92,7 @@ def __call__(self, config_path, config_env, cmd_names):
"Error reading configuration from [%s.%s.%s] (env.command_name.section) "
"in configuration file at '%s' with : %s",
config_env,
cmd_names,
self.cmd_names,
self.section,
samconfig.path(),
str(ex),
Expand Down
1 change: 1 addition & 0 deletions samcli/cli/command.py
Expand Up @@ -19,6 +19,7 @@
"samcli.commands.local.local",
"samcli.commands.package",
"samcli.commands.deploy",
"samcli.commands.delete",
"samcli.commands.logs",
"samcli.commands.publish",
"samcli.commands.pipeline.pipeline",
Expand Down
2 changes: 2 additions & 0 deletions samcli/commands/_utils/resources.py
Expand Up @@ -23,6 +23,7 @@
AWS_GLUE_JOB = "AWS::Glue::Job"
AWS_SERVERLESS_STATEMACHINE = "AWS::Serverless::StateMachine"
AWS_STEPFUNCTIONS_STATEMACHINE = "AWS::StepFunctions::StateMachine"
AWS_ECR_REPOSITORY = "AWS::ECR::Repository"

METADATA_WITH_LOCAL_PATHS = {AWS_SERVERLESSREPO_APPLICATION: ["LicenseUrl", "ReadmeUrl"]}

Expand Down Expand Up @@ -50,6 +51,7 @@
RESOURCES_WITH_IMAGE_COMPONENT = {
AWS_SERVERLESS_FUNCTION: ["ImageUri"],
AWS_LAMBDA_FUNCTION: ["Code"],
AWS_ECR_REPOSITORY: ["RepositoryName"],
}


Expand Down
6 changes: 6 additions & 0 deletions samcli/commands/delete/__init__.py
@@ -0,0 +1,6 @@
"""
`sam delete` command
"""

# Expose the cli object here
from .command import cli # noqa
101 changes: 101 additions & 0 deletions samcli/commands/delete/command.py
@@ -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()

0 comments on commit bfbcc16

Please sign in to comment.