Setting environment variables in cloudformation using command module within cfn-init -


i'm trying set environment variables through commands module within cfn-init.

"commands": {               "set-env": {                 "env": {                   "hostname": "fb-iaas.elevatebilling.com"                 },                 "cwd": "~",                 "command": "echo \"$hostname\" > test.txt"               }             }, 

and output see in cfn-init.log

2016-09-22 10:26:53,638 debug running command set-env 2016-09-22 10:26:53,639 debug no test command set-env 2016-09-22 10:26:53,655 info command set-env succeeded 2016-09-22 10:26:53,655 debug command set-env output:  

but environment variable hostname doesn't updated. can please explain doing wrong?

thanks

when variable doesn't updated, how have found out? did open "test.txt" , read piped or did ssh instance , run "echo $hostname"? reason why ask because aws docs on running commands cfn-init (http://docs.aws.amazon.com/awscloudformation/latest/userguide/aws-resource-init.html) "env" option:

env - optional. sets environment variables command. property overwrites, rather appends, existing environment.

from interpretation of , experience, environment variables set using "env" exist command in resides. if read in "test.txt" file variable set want not when run "echo $hostname" it's because variable exists command. suggest if want environment variables persist, set them using "export" in userdata section of cloudformation template.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -