[英]AWS Cloudformation: Variable not interpolated in cfn-init command
In the following Cloudformation EC2 instance declaration: 在以下Cloudformation EC2实例声明中:
MyInstance:
Type: AWS::EC2::Instance
Metadata:
Comment: Test
AWS::CloudFormation::Init:
config:
commands:
01_test:
command: "echo \"${MyEndpoint}\" > /root/test.txt"
cwd: "~"
The var MyEndpoint
is never interpolated (the file created is empty). 永远不会插值var MyEndpoint
(创建的文件为空)。
Is it a syntax issue? 这是语法问题吗?
The variable certainly exists (it is used throughout the rest of the CF template with success) 变量确实存在(成功在整个CF模板的其余部分使用)
The above does not work. 上面的方法不起作用。
One needs to use the !Sub
function 需要使用!Sub
函数
AWS::CloudFormation::Init:
config:
commands:
01_test:
command:
!Sub |
echo ${MyEndpoint} > /root/test.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.