You are on page 1of 3

# QUANDO SO TEM O DEFAULT NAO PRECISA COLOCAR O NOME DO CLUSTER

aws ecs list-clusters


aws ecs list-services --cluster default
aws ecs list-tasks --cluster default

aws ecs update-service --cluster PRIMEIRO-ECS --service sample-app-service --


desired-count 1

aws ecs describe-clusters --cluster PRIMEIRO-ECS


aws ecs describe-clusters --cluster PRIMEIRO-ECS --query 'clusters[*],
[clusterName]'

aws ecs describe-clusters --query 'clusters[*].[clusterName]' # NAO ROLA DO CMD


NORMAL SO NO GIT BACH OU POWER SHELL

aws ecs describe-tasks --cluster default --task 03284406b54149e18bc9bd725836bf83

aws ecs describe-tasks --cluster default --task 03284406b54149e18bc9bd725836bf83 --


query 'tasks[*].[cpu,memoryReservation]'
aws ecs describe-tasks --cluster default --task 03284406b54149e18bc9bd725836bf83 --
query 'tasks[*].{cpu:cpu,MEMORIA:memoryReservation}'

aws ecs list-clusters


aws ecs list-tasks
aws ecs list-task-definition -- NAO PRECISA DE CLUSTER

aws ecs list-tasks --cluster nomedocluster

# COMANDOS DE AUTO-SCALLING
aws autoscaling describe-auto-scaling-groups > SCALING

aws autoscaling set-desired-capacity --auto-scaling-group-name EC2ContainerService-


ecs-api-cluster-ec2-EcsInstanceAsg-1762V1PMY5X8U --desired-capacity 2

IMAGEM DE EXEMPLO DO EXERCICIO


https://hub.docker.com/r/rmerces/api-monolitica/

docker run --name api-mono -d -p 3000:3000 rmerces/api-monolitica

Consultando as informa��es:
http://localhost:3000/api/
http://localhost:3000/api/users
http://localhost:3000/api/threads
http://localhost:3000/api/posts
http://localhost:3000/api/users/2
http://localhost:3000/api/threads/3
http://localhost:3000/api/posts/in-thread/1
http://localhost:3000/api/posts/by-user/2

NO ECR FAZ UM NOVO REPOSITORIO


QUANDO LISTAR ELE, SELECIONA E VAI NO BOTAO VIEW PUSH COMANDS E VAI VER TODOS OS
COMANDOS ABAIXO
ANTES FAZER O AWS CONFIGURE

# fazer login no docker do ECR


aws ecr get-login-password --region us-east-2 | docker login --username AWS --
password-stdin 972366302247.dkr.ecr.us-east-2.amazonaws.com

# tag a imagem >>


docker tag rmerces/api-monolitica:latest 972366302247.dkr.ecr.us-east-
2.amazonaws.com/api-monolitica:latest

# faz push
docker push 972366302247.dkr.ecr.us-east-2.amazonaws.com/api-monolitica:latest

CASO DE ERRO
Unable to run task
No Container Instances were found in your cluster.

QUANTO FOR TESTAR A TASK, VERIFICA ISSO


VPC
Subnets
subnet-0813fc651d3a3f737
Modify auto-assign IP settings ?? TEM QUE ESTAR SIM

QUANDO FOR CRIAR O CLUSTER, SETA ISSO TAMBEM


Auto assign public IP

ANTES DE CRIAR O CLUSTER, ARRUMA A SUBNET

#PARA UMA TASK


aws ecs stop-task --task
arn:aws:ecs:us-east-2:972366302247:task/default/8ed38f72222d4496bc7488937e21535c
aws ecs stop-task --cluster api-ecs-2 --task 71ebf473941e42c890057e235cc9db46
aws ecs stop-task --cluster api-ecs-2 --task f7dfe2ff40704ac98e29c303dab0afda
aws ecs run-task --cluster api-ecs-2 --task-definition api-monolitico:1
aws ecs run-task --cluster api-ecs-2 --task-definition api-monolitico:1 --count 3

https://cursos.alura.com.br/forum/topico-erro-quando-criando-uma-tarefa-120051

--- para fargate


1) fazer o get started
2) task role = null
3) task execution = ecs
4) ver sempre o Security group
5) target group fazer por ip e ver a pora

EXERCICIOS
docker pull rmerces/api-users
docker pull rmerces/api-threads
docker pull rmerces/api-posts

vpc-03d6416e51aa33902

18.218.204.208:3000/api/users

3.239.175.36:3000/api/

aws ecr get-login-password --region us-east-2 | docker login --username AWS --


password-stdin 972366302247.dkr.ecr.us-east-2.amazonaws.com

3.94.253.183:3000/api/users
EC2Co-EcsEl-9WD7XJY3G7S1-1769479467.us-east-1.elb.amazonaws.com:3000/api/users
docker tag rmerces/api-users:latest
010973527900.dkr.ecr.us-east-1.amazonaws.com/api-users:latest
docker tag rmerces/api-users:latest
010973527900.dkr.ecr.us-east-2.amazonaws.com/api-users:latest
docker push 010973527900.dkr.ecr.us-east-1.amazonaws.com/api-users:latest

174.129.127.132:3000/api/threads
======================================
--------------------------------------
======================================

docker tag rmerces/api-threads:latest 010973527900.dkr.ecr.us-east-


1.amazonaws.com/api-threads:latest
docker push 010973527900.dkr.ecr.us-east-1.amazonaws.com/api-threads:latest

docker tag rmerces/api-posts:latest


010973527900.dkr.ecr.us-east-1.amazonaws.com/api-posts:latest
docker push 010973527900.dkr.ecr.us-east-1.amazonaws.com/api-posts:latest

010973527900.dkr.ecr.us-east-1.amazonaws.com/api-threads

API-USERS-FARGATE

https://dzone.com/articles/deploy-docker-image-to-fargate

You might also like