简体   繁体   English

AWS CloudFormation-将cfn-init源文件导入到环境中

[英]AWS CloudFormation - cfn-init source file into env

I would like to source a file containing many environment variable exports into the cf-init environment. 我想提供一个包含许多环境变量导出到cf-init环境的文件。

01_source_vars:
cwd: "/opt/easy-rsa"
test: "test -e /opt/easy-rsa/vars"
command: "source /opt/easy-rsa/vars"

I see that there is an "env" property for commands in cfn-init, however how can I use that when sourcing a file? 我看到cfn-init中有命令的“ env”属性,但是在采购文件时如何使用该属性?

The env property is optional. env属性是可选的。 I am not sure if you can use the variable into another set of command. 我不确定是否可以将变量用于另一组命令。 If you want to use it within the command, you can use multiple commands in the command using \\n You can specify more than one command under that command line using \\n for executing the command. 如果你想在命令中使用它,你可以在使用多个命令command使用\\n您可以使用\\ n作为执行命令在命令行下指定多个命令。

Please check this code below. 请在下面检查此代码。

command: "source file\n echo $variable\n ..."

If you have really long command, you can use the Fn::Join to simplify the value of command. 如果您的命令真的很长,则可以使用Fn::Join简化命令的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM