https://github.com/djcass44/aws-lambda-shellstart
AWS Lambda used for updating docker-compose deployments
https://github.com/djcass44/aws-lambda-shellstart
aws aws-lambda boto3 docker-compose lambda python
Last synced: 2 months ago
JSON representation
AWS Lambda used for updating docker-compose deployments
- Host: GitHub
- URL: https://github.com/djcass44/aws-lambda-shellstart
- Owner: djcass44
- License: apache-2.0
- Created: 2019-08-11T08:41:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-29T21:56:36.000Z (over 4 years ago)
- Last Synced: 2025-06-13T20:50:25.590Z (about 1 year ago)
- Topics: aws, aws-lambda, boto3, docker-compose, lambda, python
- Language: Python
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shellstart
This repository contains an AWS Lambda used for updating a docker-compose deployment.
This script was written using Python3.6 and therefore will probably not work with Python2.
### Clarify 'updating'
Updating in this context means the following:
1. Stop the container(s)
2. Pull for newer images
3. Start the container using the new image
The actual shell which is executed is `docker-compose stop && docker-compose pull && docker-compose up -d`, however it allows for more fine-grained control of which containers to update.
### Lambda Event Data
```json
{
"s3": {
"key": "my-key.pem",
"bucket": "my-s3-bucket"
},
"ssh": {
"target": "192.168.0.1",
"user": "ec2-user",
"directory": "/home/ec2-user/production"
},
"containers": [
"my-app-ui",
"my-app-api"
]
}
```
`ssh.target`: the host to SSH into. Can be IP or hostname
`ssh.directory`: the directory of the docker-compose.yaml/yml
`containers`: (optional) the containers to update. All if not provided
### How is it done?
1. Download SSH key from S3
2. SSH into your target
3. Execute docker-compose commands
## Contributions
Go for it! Open a merge request and I'll take a look.