Aws ecs

From Wasya Wiki
Revision as of 18:31, 28 March 2024 by Piousbox (Talk | contribs) (tasks)

Jump to: navigation, search

init

cluster

 aws ecs create-cluster --cluster-name fragile-cluster
 aws ecs delete-cluster --cluster fragile-cluster


trust relationships

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "a",
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "ecs.amazonaws.com",
                    "ecs-tasks.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

develop

task definitions

aws ecs register-task-definition \
  --cli-input-json file:////Users/piousbox/projects/ruby/wco_models/app/views/wco_hosting/ecs_task_definitions/hw1.json \
  --profile ecs_driver_1
aws ecs register-task-definition \
  --cli-input-json file:////Users/piousbox/projects/ruby/wco_models/app/views/wco_hosting/ecs_task_definitions/example1.json \
  --profile ecs_driver_1
 aws ecs list-task-definitions --profile ecs_driver_1

services

create

aws ecs create-service --cluster fragile-cluster \
  --service-name helloworld \
  --task-definition helloworld:7 \
  --desired-count 1 \
  --launch-type "FARGATE" \
  --enable-execute-command \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-002cfddc88821739a],securityGroups=[sg-0cab3a81fc072e563],assignPublicIp=ENABLED}" \
  --profile ecs_driver_1
aws ecs create-service --cluster fragile-cluster \
  --service-name example \
  --task-definition example:2 \
  --desired-count 1 \
  --launch-type "FARGATE" \
  --enable-execute-command \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-002cfddc88821739a],securityGroups=[sg-0cab3a81fc072e563],assignPublicIp=ENABLED}" \
  --profile ecs_driver_1


update

aws ecs update-service --service helloworld \
  --task-definition helloworld:8 \
  --cluster fragile-cluster \
  --enable-execute-command \
  --force-new-deployment \
  --profile ecs_driver_1
aws ecs update-service --service example \
  --task-definition example:2 \
  --cluster fragile-cluster \
  --enable-execute-command \
  --force-new-deployment \
  --profile ecs_driver_1

other

 aws ecs list-services --cluster fragile-cluster --profile ecs_driver_1
 aws ecs delete-service --cluster fragile-cluster --service helloworld5 --force --profile ecs_driver_1
 aws ecs describe-services --cluster fragile-cluster --services example --profile ecs_driver_1

tasks

 aws ecs list-tasks --cluster fragile-cluster --service example --profile ecs_driver_1
aws ecs describe-tasks --cluster fragile-cluster \
  --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/d9e610c1c21d46f08dbc399eda4965d5 \
  --profile ecs_driver_1
 aws ec2 describe-network-interfaces --network-interface-id  eni-0f1b679aec2a0d978  --profile ecs_driver_1

Task example:

aws ecs execute-command  \
  --region us-east-1 \
  --cluster fragile-cluster \
  --task d9e610c1c21d46f08dbc399eda4965d5 \
  --container d9e610c1c21d46f08dbc399eda4965d5-2347908769 \
  --command "/bin/bash" \
  --interactive \
  --profile ecs_driver_1
aws ecs execute-command  \
  --region us-east-1 \
  --cluster fragile-cluster \
  --task d9e610c1c21d46f08dbc399eda4965d5 \
  --container 8c93a9d2-7937-4b44-beb5-52b7dc18cc35 \
  --command "/bin/bash" \
  --interactive \
  --profile ecs_driver_1

Task helloworld:

aws ecs execute-command  \
  --region us-east-1 \
  --cluster fragile-cluster \
  --task f497dccfc1e542fb99202d9703019b4d \
  --container f497dccfc1e542fb99202d9703019b4d-1000299617 \
  --command "/bin/bash" \
  --interactive \
  --profile ecs_driver_1
aws ecs execute-command  \
  --region us-east-1 \
  --cluster fragile-cluster \
  --task f497dccfc1e542fb99202d9703019b4d \
  --container 8c93a9d2-7937-4b44-beb5-52b7dc18cc35 \
  --command "/bin/bash" \
  --interactive \
  --profile ecs_driver_1