株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

!Subを指定してあげることで、${AWS::Region}のようなあらかじめ定義されている変数を引っ張ってくることができる。
このメソッドに気づかづ4時間くらいあーでもないこーでもないをしていたよ。
Fn::Subの短縮形みたい。ちなみにしたのは、EFSをマウントさせるテンプレートの一部分です。

  EC2Instance:
    Type: AWS::EC2::Instance
    Metadata:
      AWS::CloudFormation::Init:
        configSets:
          ascending:
            - config1
            - config2
        config1:
          commands:
            test:
              command:  !Sub >
                mount -t nfs4 -o nfsvers=4.1 ${FileSystem}.efs.${AWS::Region}.amazonaws.com:/ /mnt
              cwd: '~'

こういう書き方も大丈夫っぽい

        config1:
          commands:
            test:
              command:  !Sub mount -t nfs4 -o nfsvers=4.1 ${FileSystem}.efs.${AWS::Region}.amazonaws.com:/ /mnt
              cwd: '~'

あ、JSONよりyamlのほうがいいっぽい。コメント文とか書けるので!

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)