I have tried launching a EC2 instance from pycharm using a Python script. As part of the launch process, I have downloaded a .sh script from s3 and have executed below commands.
commands = [
"aws s3 cp s3://sample/test.sh /home/ubuntu/test.sh",
"chmod +x /home/ubuntu/test.sh",
"sudo apt-get update",
"./test.sh"
]
However, when the last command './test.sh' is executed, I want to get out of the flow and create few more instances. But, as the script ./test.sh is a long running script, its not exiting the loop. I would like to submit the job as a background Screen job, but, was not able to open a screen using python code snippets. I am using paramiko module to connect to EC2 instance.