"EOF when reading a line", AWS lambda python

Viewed 50

I have coded this in AWS Lambda console. I have not used any python editor like sublime. I get this error message. somehow it doesn't like the line opt=int(input("Enter your option: "))

import json
import boto3
import sys

def lambda_handler(event, context):
   aws_mgmt_console = boto3.session.Session()   

   aws_mgmt_ec2 = aws_mgmt_console.resource('ec2')
        
  print('ec2 instances')    

  while True:
    print("This script performs the following actions on ec2 instance")
    print("""
        1. start
        2. stop
        3. terminate
        4. Exit""")
    opt=int(input("Enter your option: "))
    if opt==1:
            instance_id=input('Enter your EC2 Instance Id: ')
            #print(dir(my_req_instance_object))
            print("Starting ec2 instance.....")
            ec2_con_cli.start_instances(InstanceIds=[instance_id])
    elif opt==2:
            instance_id=input('Enter your EC2 Instance Id: ')
            print("Stopping ec2 instance.....")
            ec2_con_cli.stop_instances(InstanceIds=[instance_id])
    elif opt==3:
            instance_id=input('Enter your EC2 Instance Id: ')
            print("Terminating ec2 instance.....")
            ec2_con_cli.terminate_instances(InstanceIds=[instance_id])
    elif opt==4:
            print("Thank you for using this script")
            sys.exit()
    else:
        print("Your option is invalid. Please try once again")
1 Answers
Related