How to delete all services deployed with Serverless Framework
The command to delete services deployed with Serverless Framework is serverless remove.
Here’s an example of executing the serverless remove command:
$ serverless remove --verbose
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
CloudFormation - DELETE_IN_PROGRESS - AWS::CloudFormation::Stack - sample-dev
CloudFormation - DELETE_SKIPPED - AWS::Lambda::Version - SampleLambdaVersionherATbCzQsAa56CUCz1peOcJkoURkXVhc6y5bou9s8
CloudFormation - DELETE_IN_PROGRESS - AWS::Lambda::Permission - SampleLambdaPermissionEventsRuleSchedule1
CloudFormation - DELETE_SKIPPED - AWS::DynamoDB::Table - WebsitesTable
CloudFormation - DELETE_IN_PROGRESS - AWS::S3::Bucket - S3BucketResource
CloudFormation - DELETE_FAILED - AWS::S3::Bucket - S3BucketResource
CloudFormation - DELETE_COMPLETE - AWS::Lambda::Permission - SampleLambdaPermissionEventsRuleSchedule1
CloudFormation - DELETE_IN_PROGRESS - AWS::Events::Rule - SampleEventsRuleSchedule1
CloudFormation - DELETE_COMPLETE - AWS::Events::Rule - SampleEventsRuleSchedule1
CloudFormation - DELETE_IN_PROGRESS - AWS::Lambda::Function - SampleLambdaFunction
CloudFormation - DELETE_COMPLETE - AWS::Lambda::Function - SampleLambdaFunction
CloudFormation - DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - DELETE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - DELETE_IN_PROGRESS - AWS::Logs::LogGroup - SampleLogGroup
CloudFormation - DELETE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - DELETE_COMPLETE - AWS::Logs::LogGroup - SampleLogGroup
CloudFormation - DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - DELETE_FAILED - AWS::CloudFormation::Stack - sample-dev
Serverless: Operation failed!
Serverless Error ---------------------------------------
An error occurred: S3BucketResource - The bucket you tried to delete is not empty (Service: Amazon S3; Status Code: 409; Error Code: BucketNotEmpty; Request ID: xxxx; S3 Extended Request ID: xxxx).
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 8.10.0
Serverless Version: 1.35.1
As shown in the DELETE_SKIPPED and DELETE_FAILED output, these three couldn’t be deleted:
The resources couldn’t be deleted, so the CloudFormation stack also couldn’t be deleted as a result.
I deleted the DynamoDB Table, S3 Bucket, and CloudFormation that couldn’t be deleted from the AWS Console respectively.
If there’s a way to delete these from serverless commands without deleting from the AWS Console, please let me know.
That’s all from the Gemba where I want to delete all services deployed with Serverless Framework.