如何在UserData中的Cloudformation Fn :: Sub中添加两个变量 [英] How to add two variables in Cloudformation Fn::Sub in UserData

查看:64
本文介绍了如何在UserData中的Cloudformation Fn :: Sub中添加两个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够添加1个变量,但不能添加第二个变量,我是系统管理员,对YAML的了解也不多

I am able to add 1 variable but unable to add second, I am a sys admin, and not that much knowledgeable about YAML

UserData:  
    Fn::Base64: !Sub  
       - |+  
        #!/bin/bash -xe  
        NEW_HOSTNAME=${test}  
       - test:   
             Fn::FindInMap: [Regions, !Ref "AWS::Region", Name]   

我想在测试后添加另一个FindInMap变量,但我无法添加。

I would like to add another FindInMap variable after test, but I am unable to.

推荐答案

您可以做到像这样:

UserData:
  Fn::Base64: !Sub
    - |
      #!/bin/bash -xe
      foo=${foo}
      baz=${baz}
    - foo: !FindInMap [FooMap, Foo, Value]
      baz: !FindInMap [FooMap, Baz, Value]

它也可以格式化为:

UserData:
  Fn::Base64: !Sub
    - |
      #!/bin/bash -xe
      foo=${foo}
      baz=${baz}
    - {
        foo: !FindInMap [FooMap, Foo, Value],
        baz: !FindInMap [FooMap, Baz, Value]
      }

另请参阅 <$的文档c $ c> Fn :: FindInMap 函数。

See also docs for the Fn::FindInMap function.

请注意,我删除了 | + -这是一项YAML功能,它表示保留尾随的换行符。

Note that I removed the |+ - which is a YAML feature and says to keep the trailing newlines. It isn't really required here.

这篇关于如何在UserData中的Cloudformation Fn :: Sub中添加两个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆