I've got a Lambda function written in Python using Boto3 and setup to fire off when a file is put into an S3 bucket. I want to copy that file to another S3 bucket across account. Here is the code:
source = boto3.resource('s3')
destination = boto3.resource('s3',
aws_access_key_id='<redacted>',
aws_secret_access_key='<redacted>')
source_bucket = source.Bucket(bucket)
destination_bucket = destination.Bucket('targetBucket')
copy_source = {
'Bucket': bucket,
'Key': key
}
destination_bucket.copy(copy_source, key)
When the Lambda function fires, everything seems to go well, but the copy never happens. When that line fires off, I get the following message in my logs. It looks like the connection to the S3 bucket is timing out. I've verified that it doesn't appear to be a permissions issue.
[INFO] 2017-01-25T19:33:59.400Z c942ee38-e334-11e6-850d-45d8f93ed656 Starting new HTTPS connection (1): [source-bucket].s3.amazonaws.com
Would anyone have any ideas?