Skip to content

Instantly share code, notes, and snippets.

@spdrman
Created June 8, 2018 21:38
Show Gist options
  • Save spdrman/d06e946ea6ab57957e549b60222f26dd to your computer and use it in GitHub Desktop.
Save spdrman/d06e946ea6ab57957e549b60222f26dd to your computer and use it in GitHub Desktop.
Use Boto3 to upload and delete an object from an AWS S3 bucket using given credentials
import boto3
session = boto3.Session(
aws_access_key_id="id",
aws_secret_access_key="secret",
region_name="us-east-1"
)
s3 = session.resource("s3")
obj = s3.Object("mybucket", "test.txt")
obj.put(Body="testing")
# A prompt to stop and check the object was created
input("Object created, waiting for input to delete")
obj.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment