45
17

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.

TerraformでFargateを扱う際にはまったポイントまとめ

Posted at

はじめに

Terraformでインフラ構築(AWS)を勉強していて、Fargateを扱う際にはまったポイントをまとめました。

バージョン

  • Terraform v0.12.1

はまったポイント

エラー内容

Error: ClientException: No Fargate configuration exists for given values.

原因

タスク定義でFargate起動タイプを選択している場合、CPU, Memoryは以下の組み合わせから選ばなくてはならないが、

  cpu = 128
  memory = 256

のように設定していた。

CPU value Memory value (MiB)
256 (.25 vCPU) 512 (0.5GB), 1024 (1GB), 2048 (2GB)
512 (.5 vCPU) 1024 (1GB), 2048 (2GB), 3072 (3GB), 4096 (4GB)
1024 (1 vCPU) 2048 (2GB), 3072 (3GB), 4096 (4GB), 5120 (5GB), 6144 (6GB), 7168 (7GB), 8192 (8GB)
2048 (2 vCPU) Between 4096 (4GB) and 16384 (16GB) in increments of 1024 (1GB)
4096 (4 vCPU) Between 8192 (8GB) and 30720 (30GB) in increments of 1024 (1GB)

参考

No Fargate configuration exists for given values
https://code.thebur.net/2018/05/11/no-fargate-configuration-exists-for-given-values/

指定された CPU またはメモリの値が無効
https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/task-cpu-memory-error.html


エラー内容

Error: ClientException: Fargate requires task definition to have execution role ARN to support ECR images.

原因

  • execution_role_arnを指定する必要があった

参考

terraformのmoduleで定義したresouseにアクセスするにはoutputしないとダメ
http://www.mpon.me/entry/2016/12/13/030907


エラー内容

Error: InvalidParameterException: Network Configuration must be provided when networkMode 'awsvpc' is specified.

原因

  • network_configurationを設定する必要があった

参考


エラー内容

Error: Incorrect attribute value type
Inappropriate value for attribute "subnets": element 0: string required.

解決方法

flattenを用いる

参考

Terraform 0.12 + vpc module v2.2 (Inappropriate value for attribute "subnet_ids": element 0: string required.) #271
https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/271

その他はまったポイント

0.11と0.12での記述の仕方の違い

  • 主に ブロックタイプ (attr { … } という波括弧で記述する属性)と マップ (attr = { key = value } という記述をする属性) ではまりました
  • 参考

タイポ

  • 疲れていると謎のタイポをしています
45
17
1

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
45
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?