Skip to content

Instantly share code, notes, and snippets.

@buddylindsey
Created January 7, 2020 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddylindsey/526a9c3c96075796a0f0c9106274d6c2 to your computer and use it in GitHub Desktop.
Save buddylindsey/526a9c3c96075796a0f0c9106274d6c2 to your computer and use it in GitHub Desktop.

boto3 does not have a built-in sync ability, but awscli does. Since awscli is just a python package I figured there had to be a way to use the sync command. Here is how.

pip install boto3
pip install awscli

Run the code in the sync.py file.

from argparse import Namespace
from botocore.session import get_session
from awscli.customizations.s3.subcommands import SyncCommand
global_args = Namespace()
global_args.region = 'us-east-2'
global_args.endpoint_url = None
global_args.verify_ssl = None
# get standard boto/awscli session information from your environment for
# getting and setting credentials and other config.
session = get_session()
sync_command = SyncCommand(session)
sync_command(['/tmp/site/build/', 's3://bucket-name'], global_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment