aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Provide a simple way of using the functionality provided by this tool as a library

Open boosh opened this issue 12 years ago • 3 comments

It'd be great if there was a simple way to import the functionality offered by aws cli as a library. Scripts importing that library could then use these functions as primitives making it simple to write custom, higher-level wrappers, etc. without needing to interact directly with boto. This would also let them catch exceptions and handle errors properly.

Currently the simplest way seems to just be shelling out to aws cli which isn't as flexible, especially from the perspectives of error handling, performance, security, etc.

If this is already possible, please let me know.

boosh avatar Dec 04 '13 17:12 boosh

I would also love to have this feature.

ghost avatar Dec 18 '13 19:12 ghost

+1 this would be extremely useful

radekdymacz avatar Jan 03 '14 09:01 radekdymacz

from awscli import clidriver


aws = clidriver.create_clidriver()
# Make sure to leave out the 'aws' bit.
# command = "s3 ls".split(" ")
command = ['s3', 'ls']
aws.main(command)

This is possible from a fresh install via pip with no special modification. I absolutely cannot recommend this, however. We strive not to make changes that break expectations with regards to the results returned by the CLI, but we make no such promises about the internals. We could make major changes, and you'd be left with an application that cannot get new services / features because the cost of updating is too high. If you need more than what the CLI has to offer, I recommend you make use of one of the many SDKs we have available. The current python SDK, boto3, is quite nice and easy to use. And if you don't want to use python, there's plenty of other languages to choose from.

JordonPhillips avatar Oct 09 '15 20:10 JordonPhillips