{"action":"closed","issue":{"url":"https://api.github.com/repos/beelit94/python-terraform/issues/34","repository_url":"https://api.github.com/repos/beelit94/python-terraform","labels_url":"https://api.github.com/repos/beelit94/python-terraform/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/beelit94/python-terraform/issues/34/comments","events_url":"https://api.github.com/repos/beelit94/python-terraform/issues/34/events","html_url":"https://github.com/beelit94/python-terraform/issues/34","id":297180191,"number":34,"title":"Run python-terraform multiple times (in loop)","user":{"login":"dragan1979","id":32413042,"avatar_url":"https://avatars1.githubusercontent.com/u/32413042?v=4","gravatar_id":"","url":"https://api.github.com/users/dragan1979","html_url":"https://github.com/dragan1979","followers_url":"https://api.github.com/users/dragan1979/followers","following_url":"https://api.github.com/users/dragan1979/following{/other_user}","gists_url":"https://api.github.com/users/dragan1979/gists{/gist_id}","starred_url":"https://api.github.com/users/dragan1979/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dragan1979/subscriptions","organizations_url":"https://api.github.com/users/dragan1979/orgs","repos_url":"https://api.github.com/users/dragan1979/repos","events_url":"https://api.github.com/users/dragan1979/events{/privacy}","received_events_url":"https://api.github.com/users/dragan1979/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-14T17:25:30Z","updated_at":"2018-02-14T22:37:14Z","closed_at":"2018-02-14T22:37:14Z","author_association":"NONE","body":"Hi,\r\n\r\ni'm new to python. I created a script to iterate through JSON file to find field email address, and remove part after @. This value is username for EC2 instance which will be created using terraform.For every user number of instances will be prompted interactively. (Terraform will be invoked from python script). Everything works fine when only one email is specified in JSON,but if more than one user is specified, code will be execured only once, I need when one iteration is finishes, run again for new user (ask for number of instances), create machine then run for as many users found in JSON file\r\n\r\nHere is my code:\r\n\r\n`#!/bin/python\r\nimport json\r\nfrom pprint import pprint\r\nfrom python_terraform import *\r\n \r\n \r\n \r\n \r\ndef myfunc(int):\r\n \r\n  tf = Terraform(working_dir='/home/ja/terraform-course/demo-2b', variables={'count':enter,'INSTANCE_USERNAME':user})\r\n  tf.plan(no_color=IsFlagged, refresh=False, capture_output=True)\r\n  approve = {\"auto-approve\": True}\r\n  print(tf.plan())\r\n  print(tf.apply(**approve))\r\n  return\r\n \r\n \r\n \r\njson_data=open('./my.json')\r\ndata = json.load(json_data)\r\n \r\njson_data.close()\r\n \r\nfor i in range (0, len (data['customers'])):\r\n    #print data['customers'][i]['email']\r\n    k=data['customers'][i]['email']\r\n    #print(k.split('@')[0])\r\n    user=k.split('@')[0]\r\n    if (i) !=0:\r\n       continue\r\n    #print(user)\r\n    enter = int(input('Enter number of instances: '))\r\n    myfunc(enter)`\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n"}}
{"actor":{"display_login":"dragan1979"}}