LoginSignup
0
2

More than 5 years have passed since last update.

YAMLで#をエスケープする

Last updated at Posted at 2019-02-12

AWS IoTのトピックルールをCloudFormationで作成したときに引っかかったのでメモ。

YMLで#をエスケープするためには、全体を"または'で囲めば良い。

test.yml
'#test'

おまけ

この記事は、CloudFormationでAWS IoTのSQLを記述しようとしたときに、「あれ、#ってエスケープ必要じゃね」と思ったため、書き始めた記事だった。

だが、いずれにせよAWS IoTのSQLは、以下のように記述すればそのまま通ることがわかった。
調べて損した

AWSIoT.yml
  IoTTopicRule:
    Type: AWS::IoT::TopicRule
    Properties:
      RuleName: !Sub "${AWS::StackName}-KinesisRule"
      TopicRulePayload: 
        Actions:
          - 
            Firehose:
              DeliveryStreamName: !Ref deliverystream
              RoleARN: !GetAtt FirehoseRole.Arn
              Separator: ','
        AwsIotSqlVersion: 2016-03-23
        RuleDisabled: True
        Sql: !Sub Select * From ''${AWS::StackName}Gatewaytopic/#''

*追記
そもそもシングルクォートのエスケープすらいらなかった。また、スタックネームにはハイフンが含まれているため、利用できなかった。
つまり、正しくはこう。

AWSIoT.yml
  IoTTopicRule:
    Type: AWS::IoT::TopicRule
    Properties:
      RuleName: !Sub "${Konst}-KinesisRule"
      TopicRulePayload: 
        Actions:
          - 
            Firehose:
              DeliveryStreamName: !Ref deliverystream
              RoleARN: !GetAtt FirehoseRole.Arn
              Separator: ','
        AwsIotSqlVersion: 2016-03-23
        RuleDisabled: True
        Sql: !Sub Select * From '${Konst}Gatewaytopic/#'

参考

Write # in yaml (in the string)

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