Help us understand the problem. What is going on with this article?

awscli ECS 関連コマンドメモ

More than 1 year has passed since last update.

主にコピペ用。

コマンドメモ

### 0. 環境変数
# CLUSTER_NAME_OR_ARN はそれぞれの環境に合わせて書き換えること
export CLUSTER_NAME_OR_ARN=<ECSクラスター名またはARN>

### 1. ヘルプ表示
aws ecs help
aws ecs <COMMAND> help

### 2. ECSクラスター一覧表示
aws ecs list-clusters
aws ecs list-clusters --output text 
aws ecs list-clusters --output text | sed -e 's/\s/ /g' | cut -d ' ' -f2

### 3. ECSクラスター詳細表示
aws ecs describe-clusters --cluster $CLUSTER_NAME_OR_ARN
aws ecs describe-clusters --cluster $CLUSTER_NAME_OR_ARN --output text

# ECSクラスターは --cluster または --clusters オプションにてスペース区切りで列挙することで複数指定可能
# 例: 
# aws ecs describe-clusters --clusters <CLUSTER_NAME_OR_ARN> <CLUSTER_NAME_OR_ARN2> <CLUSTER_NAME_OR_ARN3> ...

### 4. ECSサービス一覧表示
aws ecs list-services --cluster $CLUSTER_NAME_OR_ARN
aws ecs list-services --cluster $CLUSTER_NAME_OR_ARN --output text
aws ecs list-services --cluster $CLUSTER_NAME_OR_ARN --output text | sed -e 's/\s/ /g' | cut -d ' ' -f2

#### 4.1. ECSサービスARN環境変数セット
export ECS_SERVICE_ARN=arn:aws:ecs:<REGION>:<ACCOUNT_ID>:service/<SERVICE_NAME>
# or
export ECS_SERVICE_NAME=<ECSサービス名>
export ECS_SERVICE_ARN="$(aws ecs list-services --cluster $CLUSTER_NAME_OR_ARN --output text | sed -e 's/\s/ /g' | cut -d ' ' -f2 |grep $ECS_SERVICE_NAME)"

### 5. ECSサービス詳細表示
aws ecs describe-services --cluster $CLUSTER_NAME_OR_ARN --services $ECS_SERVICE_ARN

### 6. ECSタスク一覧表示
aws ecs list-tasks --cluster $CLUSTER_NAME_OR_ARN --service-name $ECS_SERVICE_ARN
aws ecs list-tasks --cluster $CLUSTER_NAME_OR_ARN --service-name $ECS_SERVICE_ARN --output text
aws ecs list-tasks --cluster $CLUSTER_NAME_OR_ARN --service-name $ECS_SERVICE_ARN --output text | sed -e 's/\s/ /g' | cut -d ' ' -f2

#### 6.1 ECSタスク環境変数セット
export ECS_TASK_ARNS="$(aws ecs list-tasks --cluster $CLUSTER_NAME_OR_ARN --service-name $ECS_SERVICE_ARN --output text | sed -e 's/\s/ /g' | cut -d ' ' -f2 | tr '\n' ' ')"

### 7. ECSタスク詳細表示
aws ecs describe-tasks --cluster $CLUSTER_NAME_OR_ARN --tasks $(echo $ECS_TASK_ARNS)
aws ecs describe-tasks --cluster $CLUSTER_NAME_OR_ARN --tasks $(echo $ECS_TASK_ARNS) --output text

随時追加予定。

参考

notakaos
東京在住のWeb Developer
yumemi
みんなが知ってるあのサービス、実はゆめみが作ってます。スマホアプリ/Webサービスの企画・UX/UI設計、開発運用。Swift, Kotlin, PHP, Vue.js, React.js, Node.js, AWS等エンジニア・クリエイターの会社です。東京(三軒茶屋)/京都(四条烏丸)/札幌/大阪/福岡に展開中!Twitterで情報配信中https://twitter.com/yumemiinc
http://www.yumemi.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした