Skip to content

Commit

Permalink
Copy external product images from source to target bucket (#631)
Browse files Browse the repository at this point in the history
Copy external product images from source staging bucket to target bucket
  • Loading branch information
dpsaws authored Sep 6, 2024
1 parent cc12f15 commit 1079f9e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion aws/cloudformation-templates/base/cloudfront.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,15 @@ Resources:
s3 = boto3.resource('s3')
target_bucket = s3.Bucket(target_bucket_name)
# Sync custom images from SourceBucket to TargetBucket
source_bucket = s3.Bucket(source_bucket_name)
for obj in source_bucket.objects.filter(Prefix=source_path + 'images/'):
source = { 'Bucket': source_bucket_name, 'Key': obj.key }
target_key = obj.key.replace(source_path, '')
print(f'Copying {source} to {target_bucket_name}/{target_key}')
target_bucket.copy(source, target_key)
# For all files in tmpdirname
for root, dirs, files in os.walk('/tmp/images'):
for filename in files:
Expand Down

0 comments on commit 1079f9e

Please sign in to comment.