2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ECSのtask definitionで複数フィールドでクエリしたいとき

Last updated at Posted at 2021-10-04

jqのドキュメントと照らし合わせながら見つけました

方法

以下のようにやれば、taskDefinitionArncontainerDefinitionsが両方取れます。
もっといい方法がある気もしますが、、

$ aws ecs describe-task-definition --task-definition task \
--query 'taskDefinition | {
taskDefinitionArn: taskDefinitionArn,
containerDefinitions: containerDefinitions
}'

{
    "taskDefinitionArn": "arn:aws:ecs:ap-northeast-1:xxxxx:task-definition/task:12",
    "containerDefinitions": [
        {
--- 略 ---

配列ぽくとりたいとき

aws ecs describe-task-definition --task-definition task --query 'taskDefinition | [taskDefinitionArn, containerDefinitions]'

おまけ

もともと以下のようにtaskDefinitionを取得してgithub actionsに突っ込んでいたのですが、 resource is not in the state servicesStable というエラーが出ていました。

$ aws ecs describe-task-definition --task-definition task \
--query taskDefinition

以下のようにクエリすることで回避できました。

$ aws ecs describe-task-definition --task-definition task \
--query 'taskDefinition |
{
        ipcMode: ipcMode,
        executionRoleArn: executionRoleArn,
        containerDefinitions: containerDefinitions,
        placementConstraints: placementConstraints,
        memory: memory,
        taskRoleArn: taskRoleArn,
        family: family,
        pidMode: pidMode,
        requiresCompatibilities: requiresCompatibilities,
        networkMode: networkMode,
        cpu: cpu,
        inferenceAccelerators: inferenceAccelerators,
        proxyConfiguration: proxyConfiguration,
        volumes: volumes
}' > task-definition.json
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?