LoginSignup
1
0

More than 1 year has passed since last update.

【CloudFormation】Template format error: Any Properties member must be an object.

Posted at

この記事について

CloudFormationにおける表題のエラーへの対処法について書いた記事です。

CloudFormationを使っていて、本記事タイトルのようなエラーが出て詰まったのですが、ググっても情報を上手く見つけることが出来ませんでした。
同様のエラーが起きた方のお役に少しでも立てればと思い、本記事を公開することにしました。

症状

「オブジェクト」で記載すべき箇所を、「リスト」で書く。
下記の例では「DefaultActionsの箇所」が誤っている。

  ALB1: 
    Type: "AWS::ElasticLoadBalancingV2::Listener"
    Properties: 
      - DefaultActions: 
          - TargetGroupArn: !Ref ELB
            Type: forward
      LoadBalancerArn: !Ref TG
      Port: 80
      Protocol: HTTP

以下のようなエラーが出る。

Template format error: Any Properties member must be an object.

解決

上記ではDefaultActionsを「リスト」として書いているが、
「オブジェクト」として書き直すとエラーを直せる。

  ALB1: 
    Type: "AWS::ElasticLoadBalancingV2::Listener"
    Properties: 
      DefaultActions: 
        - TargetGroupArn: !Ref ELB
          Type: forward
      LoadBalancerArn: !Ref TG
      Port: 80
      Protocol: HTTP

考察

リストはオブジェクトに含むという思い込みがあったので、エラーメッセージを読んでも理解できなかったために詰まったと考えられる。
yamlはインデントで気軽に書けるだけに、慣れないうちはこうした苦労はつきものなのかもしれない。

まとめ

本来オブジェクトにするところを誤ってリストにするとこのエラーが出ることを知ったので、今後は同様のエラーが出ても対応することができる。

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