Skip to content

Instantly share code, notes, and snippets.

@shubhamwagh
Created September 17, 2019 17:46
Show Gist options
  • Save shubhamwagh/8dd53aa26cb86f475ce9366055074ee8 to your computer and use it in GitHub Desktop.
Save shubhamwagh/8dd53aa26cb86f475ce9366055074ee8 to your computer and use it in GitHub Desktop.
AWS s3 bucket delete and upload
import boto3
session = boto3.Session(
aws_access_key_id='AWS_ACCESS_KEY_ID',
aws_secret_access_key='AWS_SECRET_KEY',
)
s3 = session.resource('s3')
bucket = s3.Bucket('bucket-name')
bucket.objects.all().delete()
s3.meta.client.upload_file(Filename='filename-with-path', Bucket='qbot.co.robot.software.deployment.mk7', Key='only-filename-in-the-bucket')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment