
Fn::Sub - AWS CloudFormation
The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify. In your templates, you can use this function to construct commands or outputs that include values that aren't available until you create or update a stack.
Use the Fn::Sub function in AWS CloudFormation | AWS re:Post
You can use the Fn::Sub intrinsic function to substitute supported functions or to substitute variables in an input string with values that you specify. To substitute the value from supported functions, you must use variable map with the name and value as shown below: JSON: { "Fn::Sub" : [ String, { Var1Name: Var1Value, Var2Name: Var2Value ...
Understanding AWS CloudFormation !Sub Syntax - fischco.org
2017年9月4日 · This article aims to demonstrate some of the many uses of the Fn::Sub syntax in the AWS CloudFormation service. Topics include: Basic Fn::Sub and !Sub syntax; Short and long form syntax; Nested Sub and ImportValue statements; Background. About a year ago (Sept 2016, along with YAML support) AWS added a new intrinsic function to CloudFormation ...
Fn::Sub for multi-line userdata on CloudFormation (JSON)
2024年1月21日 · To write multi-line strings that require variable substitution in CloudFormation JSON templates, use the combination of Fn::Join and per-line Fn::Sub function calls. Or alternatively, decide if this is too much of a hassle and use YAML instead.
What does "!Sub |" mean in AWS UserData field with YAML syntax?
The intrinsic function Fn::Sub (YAML !Sub) substitutes variables (such as the ${AWS::StackName} variable in your example) in an input string with values that you specify. In your templates, you can use this function to construct commands or outputs that include values that aren't available until you create or update a stack.
CloudFormation protip: use !Sub instead of !Join
I find these very hard to comprehend, and my protip for you today is to use Fn::Sub (or the !Sub shorthand) instead. Many folks would use Fn::Sub when they need to reference pseudo parameters such as AWS::Region and AWS::AccountId, for example:!Sub 'arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:vpc/${vpc}'
How use Fn::Include and Fn::Sub together? - Stack Overflow
2019年8月25日 · One solution would be to include the state machine definition in the CloudFormation template directly, without resorting to Fn::Transform and Fn::Include, which would allow you to use Fn::Sub to replace the placeholders.
【CloudFormation】組み込み関数Fn::Subが意外と便利な件 - Qiita
CloudFormation の組み込み関数 !Sub は、 !Ref や !GetAtt など、他の組み込み関数の代わりとしても使用することができます。 !Ref Resource と !Sub ${Resource} は同義です。 ただし、!Ref の方が ${} が不要な分、シンプルなので、単体ではあえて !Sub を使うメリットはありません。 !Sub が有用なのはこのケースです。 以下のように、ARN を !Join で結合している記法を割と見かけますが、!Sub を使うと、一行でシンプルに書けて可読性も良くなります。 !GetAtt …
How to use Fn::If with array values in cloud formation templates
2019年7月10日 · In the policy document I want to set the the principals depending on the stage (whether it is prod or test). I can use Fn:If easily if there is only one principal for both stages. But I have more than one principals for each stage and Fn:If only allows you to assign a value, not a collection according to my understanding (correct me if I am wrong).
Fn::Sub - AWS CloudFormation
Fn::Sub 函数将输入字符串 www.$ {Domain} 中的 $ {Domain} 替换为引用在同一堆栈模板中定义的 RootDomainName 参数的 Ref 函数值。例如,如果根域名称为“mydomain.com”,则该资源生成的名称为“www.mydomain.com”。