How to use awscli inside python script?

amazon-ec2, amazon-web-services, aws-cli, python

Solution

The CLI would be more suited for the shell prompt, for a better python API, check the boto library. This example shows how to launch an instance: http://boto.readthedocs.org/en/latest/ec2_tut.html

Problem

I'm using aws ec2 service with awscli. Now I want to put all the commands I type in the console into a python script. I see that if I write `import awscli` inside a python script it works fine but I don't understand how to use it inside the script. For instance how do I execute the commands `aws ec2 run-instances <arguments>` inside the python script after `import awscli`? Just to make it clear, I'm not looking for a solution like `os.system('aws ec2 run-instances <arguments>')`, I'm looking for something like ``` import awscli awscli.ec2_run-instances(<arguments>) ```

Original source