Created
July 6, 2021 22:12
-
-
Save asraful/0c426fb70e5e2b43f83f86c0aea2ccbb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Step 1: Configure the Amazon ECS CLI | |
ecs-cli configure --cluster ec2-tutorial --default-launch-type EC2 --config-name ec2-tutorial --region us-west-2 | |
ecs-cli configure profile --access-key AWS_ACCESS_KEY_ID --secret-key AWS_SECRET_ACCESS_KEY --profile-name ec2-tutorial-profile | |
Step 2: Create Your Cluster | |
ecs-cli up --keypair id_rsa --capability-iam --size 2 --instance-type t2.medium --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Step 3: Create a Compose File | |
docker-compose.yml | |
version: '3' | |
services: | |
web: | |
image: amazon/amazon-ecs-sample | |
ports: | |
- "80:80" | |
logging: | |
driver: awslogs | |
options: | |
awslogs-group: ec2-tutorial | |
awslogs-region: us-west-2 | |
awslogs-stream-prefix: web | |
ecs-params.yml | |
version: 1 | |
task_definition: | |
services: | |
web: | |
cpu_shares: 100 | |
mem_limit: 524288000 | |
Step 4: Deploy the Compose File to a Cluster | |
ecs-cli compose up --create-log-groups --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Step 5: View the Running Containers on a Cluster | |
ecs-cli ps --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Step 6: Scale the Tasks on a Cluster | |
ecs-cli compose scale 2 --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
ecs-cli ps --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Step 7: Create an ECS Service from a Compose File | |
ecs-cli compose down --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
ecs-cli compose service up --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Step 8: View your Web Application | |
Enter the IP address for the task in your web browser and you should see a webpage that displays the Simple PHP App web application. | |
Step 9: Clean Up | |
ecs-cli compose service rm --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
ecs-cli down --force --cluster-config ec2-tutorial --ecs-profile ec2-tutorial-profile | |
Source : https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment