1
1

More than 3 years have passed since last update.

[CloudFormation]WebACLAssociationのArnが指定できない

Posted at

問題

AWS::WAFv2::WebACLAssociationでWebACLとALBの紐付けをしようとするが、スタック作成時に「WebACLがArnで指定できてない」とFailedする。

参照値を見ると、!Ref MyWebACLでは「my-webacl」のようにIDが出力されている。(!Ref MyALBではちゃんとArnが出てるのに...)

before.yml
  WebACLAssociation:
    Type: AWS::WAFv2::WebACLAssociation
    Properties:
      WebACLArn: !Ref MyWebACL
      ResourceArn: !Ref MyALB

解決策

ALBとWebACLではデフォルトの戻り値が異なる。

ALBではArn (ドキュメントはこちら)
WebACLではphysical ID (ドキュメントはこちら)

ドキュメントに従い、Fn::GetAttでArnを使えばOK。

after.yml
  WebACLAssociation:
    Type: AWS::WAFv2::WebACLAssociation
    Properties:
      WebACLArn:
        Fn::GetAtt: MyWebACL.Arn
      ResourceArn: !Ref MyALB

さいごに

ちゃんとドキュメントを読むって大事。つい面倒くさがって適当にググっちゃうけど。

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