1
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.

【AWS】【CircleCI】【Terraform】【Rails】CircleCIでECSに自動デプロイをする時にハマったとこ

Posted at

状況

config.yml
version: 2.1 
orbs:
  aws-ecr: circleci/aws-ecr@6.11.0
  aws-ecs: circleci/aws-ecs@1.2.0

Orbsを使用してデプロイを実行しようとすると以下のエラーが発生

An error occurred (ClientException) when calling the DescribeTaskDefinition operation: Unable to describe task definition.
スクリーンショット 2020-07-27 15.36.22.png

エラー内容と対処

調べると、aws ecs describe-task-definitionコマンドを叩いて、うまくいかなかった時のエラーであるとわかる

circleciのlogから、awsコマンドを叩いてる部分を探すと以下の記述に出会う

circleci
PREVIOUS_TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition ${MY_APP_PREFIX}-service --include TAGS)

注意するのは、引っ張りたいタスク定義のfamilyの末尾は-serviceである必要があるということ

なので、Terraformでは

task_definition.tf
resource "aws_ecs_task_definition" "manabi-app" {
  family = "app名" #これをapp名-serviceに変更
  container_definitions = file("./container_definitions/service.json")
  task_role_arn = data.terraform_remote_state.iam.outputs.ecs_task_role_arn
  execution_role_arn = data.terraform_remote_state.iam.outputs.ecs_task_role_arn
  network_mode = "bridge"
}

うまくデプロイできた!

1
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
1
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?