diff --git a/bluegreen.py b/bluegreen.py index ff3b8b7..d529123 100755 --- a/bluegreen.py +++ b/bluegreen.py @@ -7,7 +7,7 @@ import time def main(argv): - helptext = 'bluegreen.py -f -a -c -t ' + helptext = 'bluegreen.py -f -a -c -t -e ' try: opts, args = getopt.getopt(argv,"hf:a:c:t:e:",["folder=","ami=","command=", "timeout=", "environment="]) @@ -263,12 +263,14 @@ def buildTerraformVars (blueMax, blueMin, blueDesired, blueAMI, greenMax, greenM 'green_ami': greenAMI } out = [] + + # When using terraform environments, set the environment tfvars file if environment != None: - for key, value in variables.iteritems(): - out.append('-var \'%s={ %s = "%s" }\'' % (key, environment, value)) - else: - for key, value in variables.iteritems(): - out.append('-var \'%s=%s\'' % (key, value)) + out.append('-var-file=%s' % (environment)) + + for key, value in variables.iteritems(): + out.append('-var \'%s=%s\'' % (key, value)) + return ' '.join(out) if __name__ == "__main__":