8
0

More than 3 years have passed since last update.

TerraformでCloudFrontにACL(AWS WAF)を定義するときのエラー対処方法

Posted at

エラー内容

TerraformでCloudFrontにWeb ACLを付与しようとした際にプロビジョニングエラーが発生しました。

resource "aws_cloudfront_distribution" "sample" {
  web_acl_id = ${var.waf_web_acl_id} # ex) bbbbbbbb-xxxx-yyyy-zzzz-aaaaaaaaaaa
}
Error: error creating CloudFront Distribution: InvalidWebACLId: Web ACL is not accessible by the requester.
        status code: 400, request id: 1815419a-666c-4b68-8bbe-10a5b77

対応策

AWS WAF v2を使用している場合

AWS WAF v2を使用している場合、web_acl_idにACL IDを指定するとエラーとなります。
そこで、V2ではACLのarnを指定します。

resource "aws_cloudfront_distribution" "sample" {
  web_acl_id = ${var.waf_web_acl_arn} #ex) arn:aws:wafv2:us-east-1:xxxxxxxxx:global/webacl/xxxxxxxxxx/xxxxxxxxxxx",
}

AWS WAF v1を使用している場合

AWS WAF v1を使用している場合にエラーが出る場合はTerraformを実行するIAMユーザーの権限不足が考えられます。
waf:GetWebACL権限を付与します。

【参考】AWS SDKからWAF付きのCloudFrontを作成する時に、’Web ACL is not accessible by the requester.’が出た時の対応覚書

参考

8
0
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
8
0