Last active
February 22, 2021 02:02
-
-
Save campezzi/83656ed49d0948ba7b6dfd5a4b946d4b to your computer and use it in GitHub Desktop.
Amazon ECS deployment using the ecs-cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full documentation: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI.html | |
# Replace the cluster name, keypair, exposed ports etc. as necessary. | |
# Install the ECS CLI and make it executable | |
sudo curl -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest | |
sudo chmod +x /usr/local/bin/ecs-cli | |
# Configure the CLI (login details, region and cluster name) | |
ecs-cli configure --region ap-southeast-2 --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --cluster CreateBTATaskUI | |
# Create the cluster (by default, spins a single t2.micro instance) | |
# This should be done manually once for each project | |
ecs-cli up --keypair service_stubs --capability-iam --port 5002 | |
# Bring up the service | |
ecs-cli compose --file ecs-compose.yml service up | |
# Scale the service | |
ecs-cli compose --file ecs-compose.yml service scale 3 | |
# Stop the service | |
ecs-cli compose --file ecs-compose.yml service stop | |
# Delete the service | |
ecs-cli compose --file ecs-compose.yml service rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_awesome_server: | |
image: ACCOUNT_ID_HERE.dkr.ecr.us-west-2.amazonaws.com/IMAGE_NAME:IMAGE_TAG | |
ports: | |
- "5002:80" | |
environment: | |
- SOME_ENVIRONMENT_VARIABLE=exposed_in_container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When starting a new project, configure the CLI for a new cluster named after it and run the create cluster command. This will take a few minutes as it spins up EC2 instance(s) that are pre-baked to run containers. Once that's done, you should be able to bring up the service.
Stopping/starting the service will cause the images used by the service to be re-downloaded (even if the tag hasn't changed).