6

This is a follow-up to an earlier question I had. If possible, instead of calling the AWS CLI from a Python lambda, I'd like to use Boto3 (which has S3 capabilities). However, I don't see any sync functionality in the Boto3 S3 documentation (I expected it to be under Bucket or BucketLifecycle but I checked everywhere as well).

Is it possible then to invoke S3 sync from Boto?

wishihadabettername
  • 14,231
  • 21
  • 68
  • 85

1 Answers1

7

Boto3 does not include s3 sync capabilities. That is only available via the AWS CLI tool. You can package the AWS CLI tool with your Python Lambda function by following the steps outlined in this answer.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • 2
    Thanks, Mark. I've tried over the last few minutes, and invoking `command = ["aws", "s3", "sync", source_bucket, destination_bucket]` and `results = subprocess.check_output(command, stderr=subprocess.STDOUT)` gives `"errorMessage": "[Errno 2] No such file or directory: 'aws': 'aws'",` Do I need to prefix `aws` with any hardcoded path or an environment variable? Thanks again. – wishihadabettername Jan 16 '19 at 17:14
  • Sorry, I read it was available, but didn't actually try it. Another post says it is not available by default, so I'm not sure which is true. You can package it with your Python Lambda function fairly easily though: https://stackoverflow.com/questions/33513604/call-aws-cli-from-aws-lambda – Mark B Jan 16 '19 at 17:19
  • 1
    Indeed, I've just read at https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html that Boto3 is available but not the entire AWS CLI SDK. I'll package it or perhaps try the Javascript one for convenience. – wishihadabettername Jan 16 '19 at 17:20
  • 1
    If you edit the answer with your latest comments, so that it's correct for future readers, I'll accept it as an answer. – wishihadabettername Jan 16 '19 at 17:21