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]
I would like to add another FindInMap variable after test, but I am unable to.
You can do it like this:
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash -xe
foo=${foo}
baz=${baz}
- foo: !FindInMap [FooMap, Foo, Value]
baz: !FindInMap [FooMap, Baz, Value]
It could also be formatted as:
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash -xe
foo=${foo}
baz=${baz}
- {
foo: !FindInMap [FooMap, Foo, Value],
baz: !FindInMap [FooMap, Baz, Value]
}
See also docs for the Fn::FindInMap function.
Note that I removed the |+ - which is a YAML feature and says to keep the trailing newlines. It isn't really required here.
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash
NEW_HOSTNAME=${hostName}
- {
share: !FindInMap [Regions, !Ref "AWS::Region", SHARE],
hostName: !Join ["", [!Ref Name, !FindInMap [Regions,
!Ref"AWS::Region",USERDATA] ] ]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With