https://github.com/abiydv/serverless-aws-lambda-ecs-rollback
AWS Lambda to rollback ECS deployment. Created with serverless framework and js
https://github.com/abiydv/serverless-aws-lambda-ecs-rollback
aws aws-ecs aws-ecs-cluster aws-lambda serverless serverless-framework
Last synced: 2 months ago
JSON representation
AWS Lambda to rollback ECS deployment. Created with serverless framework and js
- Host: GitHub
- URL: https://github.com/abiydv/serverless-aws-lambda-ecs-rollback
- Owner: abiydv
- License: apache-2.0
- Created: 2019-02-01T18:25:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-05T11:46:23.000Z (over 7 years ago)
- Last Synced: 2025-10-24T10:10:43.605Z (8 months ago)
- Topics: aws, aws-ecs, aws-ecs-cluster, aws-lambda, serverless, serverless-framework
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serverless: AWS Lambda to rollback AWS ECS deployment
[](https://www.codefactor.io/repository/github/abiydv/serverless-aws-lambda-ecs-rollback)





Serverless framework example to deploy AWS Lambda, which can rollback a ECS deployment to the second last 'active' task definition version. Lambda runtime used - nodejs 8.x
## Prerequisites
**1.** Install serverless. Follow this [guide](https://serverless.com/framework/docs/providers/aws/guide/installation/)
**2.** Setup aws cli with profiles matching environments/stages. A sample `~/.aws/credentials` file -
```
[dev]
aws_access_key_id = DEV_ACCESS_KEY
aws_secret_access_key = DEV_SECRET_KEY
[qa]
aws_access_key_id = QA_ACCESS_KEY
aws_secret_access_key = QA_SECRET_KEY
[prod]
aws_access_key_id = PROD_ACCESS_KEY
aws_secret_access_key = PROD_SECRET_KEY
```
## How to use
**1.** Deploy the service with `--stage dev` argument to create the **dev** stack. Use **qa** or **prod** to launch function in other environments.
***NOTE**: Create `config-qa.json` and `config-prod.json` with the respective AWS Account Id info.*
```
serverless deploy -v --stage dev
```
**2.** Invoke the lambda function
```
serverless invoke -f rollback -l --stage dev
```
**3.** Deploy only the lambda function after any change in lambda code. (Skip if no change)
```
serverless deploy -f rollback --stage dev
```
**4.** Cleanup everything
```
serverless remove -v --stage dev
```
## Contact
Drop me a note or open an issue if something doesn't work out.
Cheers! :thumbsup: