I wrote a function that asks the user some information. At the end of the task it will prompt the user to make sure if its correct. If yes or y then the function should continue. If else it should repeat the questions. I cant figure out why the function stops regardless of what the user enters:
157 def runAllfunctions():
158 # getAccessSecretName()
159 mcIPNumber()
160 makeNameMCTag()
161 makeTfvars()
162 makeMainTF()
163 Provisioners()
164 Resources()
165 Outputs()
166
167
168 def runTerraform():
169 getAccessSecretName()
170 infoCorrect = raw_input('Is the information above correct? (y or n)')
171 if infoCorrect.lower() == "yes" or "y":
172 runAllfunctions()
173 else:
174 runTerraform()
175
176 runTerraform()
What I expect to happen from the above, if the user enters anything other than yes or y it will re-run runTerraform(), which prompts the user for the information again until it is correct. Once it is correct it will go through and run the rest of the functions
Here's what I'm seeing:
When answer is not yes or y
You Entered:
Access Key: asdfds
Secret Key: asfads
Your full name is: dsafd dsafdas
Is the information above correct? (y or n)n
newnumber = 16
Your EC2 instance will tagged:
Name Tag: vlslabs16
Multicast Tag: vlslabmc, 172.16.0.16
It should have re-asked the questions again.
When answer is indeed yes or y :
python terraTFgen.py
Enter Access Key: asdfdsa
Enter Secret Key: asdfads
Enter your name: asdfads
You Entered:
Access Key: asdfdsa
Secret Key: asdfads
Your full name is: asdfads
Is the information above correct? (y or n)y
newnumber = 16
Your EC2 instance will tagged:
Name Tag: vlslabs16
Multicast Tag: vlslabmc, 172.16.0.1
^ this is correct.
What am I missing when the condition is not "yes" or "y" that is preventing the function from asking the questions again?
ps this is the function that is asking the questions in case you were curious, or if this helps
13 def getAccessSecretName():
14 global access_key, secret_key, yourName
15 access_key = raw_input("Enter Access Key: ")
16 secret_key = raw_input("Enter Secret Key: ")
17 yourName = raw_input("Enter your name: ")
18
19 print "\n\nYou Entered:"
20 print "Access Key: %s" % access_key
21 print "Secret Key: %s" % secret_key
22 print "Your full name is: %s\n" % yourName
23 with open (tfVariables,"w") as text_file:
24 text_file.writelines(['access_key = \"'+ access_key +'\"\nsecret_key = \"'+ se cret_key +'\"\n\n\n',
25 'amis = {\n',
26 ' ',
27 'us-west-1 = '+ usWest1ami +'\n',
28 ' ',
29 'us-west-1 = '+ usWest2ami +'\n',
30 ' ',
31 '}'])
Thanks!