Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tongueroo/ecs-spot-demo
ECS and Spot Fleet Demo
https://github.com/tongueroo/ecs-spot-demo
Last synced: about 1 month ago
JSON representation
ECS and Spot Fleet Demo
- Host: GitHub
- URL: https://github.com/tongueroo/ecs-spot-demo
- Owner: tongueroo
- Created: 2019-03-10T17:21:52.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T14:19:34.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T22:16:44.049Z (3 months ago)
- Size: 2.93 KB
- Stars: 17
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ECS Spot Fleet Demo
This is a sample template that demonstrates how to use ECS with Spot Fleets.
## Usage
1. Launch Stack with Spot Fleets
2. Deploy Demo App
3. Cleanup## Launch Stack
To launch the stack without a KeyName:
aws cloudformation create-stack --stack-name ecs-spot-demo --template-body file://ecs-spot-demo.yml --capabilities CAPABILITY_IAM
If you would like to launch the stack with an ssh key. Here are the commands:
# Quick way to grab first keypair on the AWS account.
KEY_NAME=$(aws ec2 describe-key-pairs | jq -r '.KeyPairs[0].KeyName')# Create a parameters file for the one required parameter in this template
cat < parameters.json
[
{
"ParameterKey": "KeyName",
"ParameterValue": "$KEY_NAME"
}
]
EOL# Launch the stack
aws cloudformation create-stack --stack-name ecs-spot-demo --template-body file://ecs-spot-demo.yml --parameters file://parameters.json --capabilities CAPABILITY_IAM## Deploy Demo App
First let's create the ECR repo and set some variables we'll need:
ECR_REPO=$(aws ecr create-repository --repository-name demo/sinatra | jq -r '.repository.repositoryUri')
VPC_ID=$(aws ec2 describe-vpcs --filters Name=tag:Name,Values="demo vpc" | jq -r '.Vpcs[].VpcId')Now we're ready to clone the demo repo and deploy an sample app to ECS with ufo. Note, you'll need Docker installed.
git clone https://github.com/tongueroo/demo-ufo.git demo
cd demo
ufo init --image $ECR_REPO --vpc-id $VPC_ID
ufo current --service demo-web
ufo ship # deploys to ECS on the Spot Fleet cluster## Cleanup
To clean up. First, delete the ECS service.
cd demo # demo project
ufo destroyDelete the ECR repo:
IMAGES=$(aws ecr list-images --repository-name demo/sinatra | jq -r '.imageIds[].imageDigest')
for i in $IMAGES; do aws ecr batch-delete-image --repository-name demo/sinatra --image-ids imageDigest=$i ; done
aws ecr delete-repository --repository-name demo/sinatraDelete the infrastructure CloudFormation stack:
aws cloudformation delete-stack --stack-name ecs-spot-demo