boto

Setting specific permission in amazon s3 boto bucket

Setting specific permission in amazon s3 boto bucket Question: I have a bucket called ‘ben-bucket’ inside that bucket I have multiple files. I want to be able to set permissions for each file URL. I’m not too sure but I’m assuming if I wanted URL for each file inside a bucket. My URL would be …

Total answers: 1

How to write a file or data to an S3 object using boto3

How to write a file or data to an S3 object using boto3 Question: In boto 2, you can write to an S3 object using these methods: Key.set_contents_from_string() Key.set_contents_from_file() Key.set_contents_from_filename() Key.set_contents_from_stream() Is there a boto 3 equivalent? What is the boto3 method for saving data to an object stored on S3? Asked By: jkdev || …

Total answers: 8

Using boto to invoke lambda functions how do I do so asynchronously?

Using boto to invoke lambda functions how do I do so asynchronously? Question: SO I’m using boto to invoke my lambda functions and test my backend. I want to invoke them asynchronously. I have noted that “invoke_async” is deprecated and should not be used. Instead you should use “invoke” with an InvocationType of “Event” to …

Total answers: 3

How to get the region of the current user from boto?

How to get the region of the current user from boto? Question: Problem: I’m trying to get the region of the authenticated user from boto3. Use case: I’m working on adding cache to https://github.com/pmazurek/aws-fuzzy-finder. I would prefer to cache the result on per-region basis. This package uses boto to get user authentication data (keys and …

Total answers: 5

Mocking boto3 S3 client method Python

Mocking boto3 S3 client method Python Question: I’m trying to mock a singluar method from the boto3 s3 client object to throw an exception. But I need all other methods for this class to work as normal. This is so I can test a singular Exception test when and error occurs performing a upload_part_copy 1st …

Total answers: 8

How to upload a file to Google Cloud Storage on Python 3?

How to upload a file to Google Cloud Storage on Python 3? Question: How can I upload a file to Google Cloud Storage from Python 3? Eventually Python 2, if it’s infeasible from Python 3. I’ve looked and looked, but haven’t found a solution that actually works. I tried boto, but when I try to …

Total answers: 5

The role defined for the function cannot be assumed by Lambda

The role defined for the function cannot be assumed by Lambda Question: I’m getting the error “The role defined for the function cannot be assumed by Lambda” when I’m trying to create a lambda function with create-function command. aws lambda create-function –region us-west-2 –function-name HelloPython –zip-file fileb://hello_python.zip –role arn:aws:iam::my-acc-account-id:role/default –handler hello_python.my_handler –runtime python2.7 –timeout 15 …

Total answers: 11

How to handle errors with boto3?

How to handle errors with boto3? Question: I am trying to figure how to do proper error handling with boto3. I am trying to create an IAM user: def create_user(username, iam_conn): try: user = iam_conn.create_user(UserName=username) return user except Exception as e: return e When the call to create_user succeeds, I get a neat object that …

Total answers: 10

How to create an ec2 instance using boto3

How to create an ec2 instance using boto3 Question: Is it possible to create an ec2 instance using boto3 in python? Boto3 document is not helping here, and I couldn’t find any helping documents online. please provide some sample codes/links. Asked By: MikA || Source Answers: The API has changed but it’s right there in …

Total answers: 5

Override S3 endpoint using Boto3 configuration file

Override S3 endpoint using Boto3 configuration file Question: OVERVIEW: I’m trying to override certain variables in boto3 using the configuration file (~/aws/confg). In my use case I want to use fakes3 service and send S3 requests to the localhost. EXAMPLE: In boto (not boto3), I can create a config in ~/.boto similar to this one: …

Total answers: 6