Skip to content

Commit

Permalink
Change from maps to tfvars (#12)
Browse files Browse the repository at this point in the history
* Change from maps to tfvars

* Fix typos

* Change order

* Expect the full path to the environment tfvars file.

* Fix typo
  • Loading branch information
MattiasGees authored Jun 29, 2017
1 parent a8b44db commit 7c0664d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bluegreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time

def main(argv):
helptext = 'bluegreen.py -f <path to terraform project> -a <ami> -c <command> -t <timeout>'
helptext = 'bluegreen.py -f <path to terraform project> -a <ami> -c <command> -t <timeout> -e <environment.tfvars path>'

try:
opts, args = getopt.getopt(argv,"hf:a:c:t:e:",["folder=","ami=","command=", "timeout=", "environment="])
Expand Down Expand Up @@ -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__":
Expand Down

0 comments on commit 7c0664d

Please sign in to comment.