Difference between revisions of "Aws ecs"
From Wasya Wiki
(→task definitions) |
(→update) |
||
(24 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
* Install session manager: | * Install session manager: | ||
** From: https://docs.aws.amazon.com/systems-manager/latest/userguide/install-plugin-macos-overview.html#install-plugin-macos | ** From: https://docs.aws.amazon.com/systems-manager/latest/userguide/install-plugin-macos-overview.html#install-plugin-macos | ||
+ | * Utilities | ||
+ | ** From: https://github.com/aws-containers/amazon-ecs-exec-checker | ||
+ | |||
+ | = init = | ||
== cluster == | == cluster == | ||
− | aws ecs create-cluster --cluster-name fragile-cluster | + | aws ecs create-cluster --cluster-name fragile-cluster --profile ecs_driver_1 |
− | + | ||
− | + | aws ecs delete-cluster --cluster fragile-cluster --profile ecs_driver_1 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== trust relationships == | == trust relationships == | ||
− | |||
<pre> | <pre> | ||
{ | { | ||
Line 47: | Line 40: | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | = develop = | ||
+ | == task definitions == | ||
+ | |||
+ | <pre> | ||
+ | aws ecs register-task-definition \ | ||
+ | --cli-input-json file:////Users/piousbox/projects/ruby/wco_models/app/views/wco_hosting/ecs_task_definitions/demmitv.json \ | ||
+ | --profile ecs_driver_1 | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> | ||
+ | |||
+ | aws ecs list-task-definitions --profile ecs_driver_1 | ||
== services == | == services == | ||
+ | === create === | ||
+ | <pre> | ||
+ | aws ecs create-service --cluster fragile-cluster \ | ||
+ | --service-name demmitv_drupal \ | ||
+ | --task-definition demmitv_drupal:1 \ | ||
+ | --desired-count 1 \ | ||
+ | --launch-type "FARGATE" \ | ||
+ | --enable-execute-command \ | ||
+ | --network-configuration "awsvpcConfiguration={subnets=[ | ||
+ | subnet-063bc531077168036],assignPublicIp=ENABLED}" \ | ||
+ | --profile ecs_driver_1 | ||
+ | </pre> | ||
<pre> | <pre> | ||
aws ecs create-service --cluster fragile-cluster \ | aws ecs create-service --cluster fragile-cluster \ | ||
--service-name example \ | --service-name example \ | ||
− | --task-definition example: | + | --task-definition example:2 \ |
--desired-count 1 \ | --desired-count 1 \ | ||
--launch-type "FARGATE" \ | --launch-type "FARGATE" \ | ||
Line 62: | Line 90: | ||
</pre> | </pre> | ||
+ | === update === | ||
− | + | <pre> | |
− | + | aws ecs update-service --service demmitv_drupal \ | |
− | + | --task-definition demmitv_drupal \ | |
+ | --cluster fragile-cluster \ | ||
+ | --enable-execute-command \ | ||
+ | --force-new-deployment \ | ||
+ | --profile ecs_driver_1 | ||
+ | </pre> | ||
<pre> | <pre> | ||
− | aws ecs update-service --service | + | aws ecs update-service --service example \ |
+ | --task-definition example:2 \ | ||
--cluster fragile-cluster \ | --cluster fragile-cluster \ | ||
--enable-execute-command \ | --enable-execute-command \ | ||
Line 75: | Line 110: | ||
</pre> | </pre> | ||
+ | === other === | ||
+ | aws ecs list-services --cluster fragile-cluster --profile ecs_driver_1 | ||
− | aws ecs | + | 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 == | == tasks == | ||
Line 83: | Line 121: | ||
aws ecs list-tasks --cluster fragile-cluster --service example --profile ecs_driver_1 | aws ecs list-tasks --cluster fragile-cluster --service example --profile ecs_driver_1 | ||
+ | aws ec2 describe-network-interfaces --network-interface-id eni-0f1b679aec2a0d978 --profile ecs_driver_1 | ||
+ | |||
+ | === Task example: === | ||
<pre> | <pre> | ||
aws ecs describe-tasks --cluster fragile-cluster \ | aws ecs describe-tasks --cluster fragile-cluster \ | ||
− | --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/ | + | --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/d9e610c1c21d46f08dbc399eda4965d5 \ |
--profile ecs_driver_1 | --profile ecs_driver_1 | ||
</pre> | </pre> | ||
− | |||
+ | <pre> | ||
+ | aws ecs execute-command \ | ||
+ | --region us-east-1 \ | ||
+ | --cluster fragile-cluster \ | ||
+ | --task d9e610c1c21d46f08dbc399eda4965d5 \ | ||
+ | --container example \ | ||
+ | --command "/bin/bash" \ | ||
+ | --interactive \ | ||
+ | --profile ecs_driver_1 | ||
+ | </pre> | ||
+ | |||
+ | === Task helloworld: === | ||
+ | <pre> | ||
+ | aws ecs describe-tasks --cluster fragile-cluster \ | ||
+ | --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/f497dccfc1e542fb99202d9703019b4d \ | ||
+ | --profile ecs_driver_1 | ||
+ | </pre> | ||
<pre> | <pre> | ||
Line 96: | Line 153: | ||
--region us-east-1 \ | --region us-east-1 \ | ||
--cluster fragile-cluster \ | --cluster fragile-cluster \ | ||
− | --task | + | --task f497dccfc1e542fb99202d9703019b4d \ |
− | --container | + | --container helloworld \ |
--command "/bin/bash" \ | --command "/bin/bash" \ | ||
--interactive \ | --interactive \ | ||
--profile ecs_driver_1 | --profile ecs_driver_1 | ||
</pre> | </pre> |
Latest revision as of 04:36, 31 March 2024
- fargate provider:
- ssh login:
- Logs:
- Install session manager:
- Utilities
Contents
init
cluster
aws ecs create-cluster --cluster-name fragile-cluster --profile ecs_driver_1
aws ecs delete-cluster --cluster fragile-cluster --profile ecs_driver_1
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/demmitv.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/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 demmitv_drupal \ --task-definition demmitv_drupal:1 \ --desired-count 1 \ --launch-type "FARGATE" \ --enable-execute-command \ --network-configuration "awsvpcConfiguration={subnets=[ subnet-063bc531077168036],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 demmitv_drupal \ --task-definition demmitv_drupal \ --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 ec2 describe-network-interfaces --network-interface-id eni-0f1b679aec2a0d978 --profile ecs_driver_1
Task example:
aws ecs describe-tasks --cluster fragile-cluster \ --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/d9e610c1c21d46f08dbc399eda4965d5 \ --profile ecs_driver_1
aws ecs execute-command \ --region us-east-1 \ --cluster fragile-cluster \ --task d9e610c1c21d46f08dbc399eda4965d5 \ --container example \ --command "/bin/bash" \ --interactive \ --profile ecs_driver_1
Task helloworld:
aws ecs describe-tasks --cluster fragile-cluster \ --tasks arn:aws:ecs:us-east-1:831556125887:task/fragile-cluster/f497dccfc1e542fb99202d9703019b4d \ --profile ecs_driver_1
aws ecs execute-command \ --region us-east-1 \ --cluster fragile-cluster \ --task f497dccfc1e542fb99202d9703019b4d \ --container helloworld \ --command "/bin/bash" \ --interactive \ --profile ecs_driver_1