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 5 years have passed since last update.

ecs run-taskやecspresso runでecs-cli compose run相当を行う

Posted at

問題

ecs-cli compose run ではコマンドを指定して実行することができる。
https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/cmd-ecs-cli-compose.html

aws ecs run-taskecspresso runでコマンドを指定するにはoverridesパラメータにjson文字列を渡す必要があり、json内にコマンドを埋め込む必要がある。

さらにコマンドは

{
  "containerOverrides": [
    {
      "name": "string",
      "command": ["string", ...],
    }
  ]
}

とarrayにする必要があり、さらにめんどくさい。

対処

jo でJSONつくったり、
envsubstやerbでテンプレート展開するのを検討したけどどちらもめんどくさいので既存でありそうな気もするけど小さいコマンドを書いた。

$ ecs-overrides -e XXX=abc -e YYY=def app echo hello world
{"ContainerOverrides":[{"Command":["echo","hello","world"],"Cpu":null,"Environment":[{"Name":"XXX","Value":"abc"},{"Name":"YYY","Value":"def"}],"Memory":null,"MemoryReservation":null,"Name":"app","ResourceRequirements":null}],"ExecutionRoleArn":null,"InferenceAcceleratorOverrides":null,"TaskRoleArn":null}%

ecspressoで使うときは↓

$ ecspresso run --config config.yaml --skip-task-definition --overrides=$(ecs-overrides app echo hello world)
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?