I tried to lookup for answer or similar behavior at various site and I dont see anyone facing this issue. That indicates that either I am not doing something correctly or I havent looked much. If you believe this is duplicate question then please point me to question where I can find answer. Thank you.
I am using EC2 Ubuntu t2.micro machine.
I have a script which checks instance "Scale in Protection Bit" and if it is not set then it terminates it.
Script Used: python script
Ways tried: update-rc.d defaults rc.local
Symptoms: If I run the script from console it works fine however, if I reboot the system, then line which checks executes "aws autoscaling describe-auto-scaling-instances --instance-id consistently fails
Code Snippet:
try: myInstanceID = subprocess.check_output(["ec2metadata","--instance-id"]) myInstanceID = myInstanceID.strip("\n") print myInstanceID except: print "Still Booting" continue
#result = subprocess.check_output(["/usr/local/bin/aws","autoscaling","describe-auto-scaling-instances","--instance-id",myInstanceID])
p = subprocess.Popen(["/usr/local/bin/aws","autoscaling","describe-auto-scaling-instances","--instance-id",myInstanceID],stdout=subprocess.PIPE)
result = p.communicate()[0]
#try:
# #result = subprocess.check_output(["aws','autoscaling','describe-auto-scaling-instances','--instance-id',myInstanceID])
# result = subprocess.check_output(["/usr/local/bin/aws","autoscaling","describe-auto-scaling-instances","--instance-id",myInstanceID])
#except:
# #print e.output
# print "ERROR"
# continue
Tried commented lines also, but same result.