Skip to content

[Feature Request] Make sam delete clean up all SAM managed resources including aws-sam-cli-managed-default stack #7782

Open
@miketheman

Description

@miketheman

Description:

After running sam package, a CloudFormation stack aws-sam-cli-managed-default is created, with 2 resources - SamCliSourceBucket & SamCliSourceBucketBucketPolicy.

Running sam delete errors out, and does not remove the bucket, policy, or CFN stack.

Steps to reproduce:

sam init a hello_world or other template, do NOT deploy yet.

$ sam package
$ sam delete --debug

Observed result:

2024-12-08 17:53:32,249 | Config file location: demo-failure/samconfig.toml
2024-12-08 17:53:32,251 | Loading configuration values from [default.['deploy'].parameters] (env.command_name.section) in config file at
'/tmp/demo-failure/samconfig.toml'...
2024-12-08 17:53:32,253 | Configuration values successfully loaded.
2024-12-08 17:53:32,253 | Configuration values are: {'stack_name': 'demo-failure', 'capabilities': 'CAPABILITY_IAM', 'confirm_changeset': True, 'resolve_s3': True}
2024-12-08 17:53:32,284 | Using config file: samconfig.toml, config environment: default
2024-12-08 17:53:32,285 | Expand command line arguments to:
2024-12-08 17:53:32,286 | --stack_name=demo-failure
	Are you sure you want to delete the stack demo-failure in the region us-east-1 ? [y/N]: y
2024-12-08 17:53:35,409 | Stack with id demo-failure does not exist
2024-12-08 17:53:35,410 | Input stack does not exists on Cloudformation
Error: The input stack demo-failure does not exist on Cloudformation in the region us-east-1
2024-12-08 17:53:35,412 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-12-08 17:53:35,507 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-12-08 17:53:35,509 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'a5fb3278-b7a7-45ab-8b85-36f2983b16c2', 'installationId': '1b202f64-2248-4ee3-afb0-9d4958012182', 'sessionId':
'44efe86e-7b7b-497e-bdeb-2674fb6a8083', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.13.0', 'samcliVersion': '1.131.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName':
'sam delete', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '9caac13c35207d92fbff4a22452366e12cee615e5da8098be2d48c907172a1de', 'initialCommit': None}, 'duration': 3128, 'exitReason':
'success', 'exitCode': 0}}]}
2024-12-08 17:53:35,509 | Unable to find Click Context for getting session_id.
2024-12-08 17:53:35,512 | Sending Telemetry: {'metrics': [{'events': {'requestId': '78924319-0757-4f07-9d22-88cdbf265d80', 'installationId': '1b202f64-2248-4ee3-afb0-9d4958012182', 'sessionId':
'44efe86e-7b7b-497e-bdeb-2674fb6a8083', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.13.0', 'samcliVersion': '1.131.0', 'commandName': 'sam delete', 'metricSpecificAttributes': {'events': [{'event_name':
'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '8046f296c6db4b8d9aa416cab9dca9a4', 'time_stamp': '2024-12-08 22:53:32.248', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value':
'.toml', 'thread_id': '77d3177873fb41e78036ba2241a96b82', 'time_stamp': '2024-12-08 22:53:32.284', 'exception_name': None}]}}}]}
2024-12-08 17:53:35,770 | Telemetry response: 200
2024-12-08 17:53:35,772 | Telemetry response: 200

Expected result:

The bucket, artifacts, polciy, and cloudformation stack are removed completely.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.131.0",
  "system": {
    "python": "3.13.0",
    "os": "macOS-15.1.1-x86_64-i386-64bit-Mach-O"
  },
  "additional_dependencies": {
    "docker_engine": "27.3.1",
    "aws_cdk": "Not available",
    "terraform": "1.5.7"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-feedbackNeeds feedback from the community (are you also interested in/experiencing this?)type/featureFeature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions