These two different lambda functions will allow you to copy objects to another bucket when there is a put event, and delete objects when there is a delete event in the source bucket.
There are 2 functions for copying and deleting objects so use it accordingly however it meets your needs.
- IAM Role Policy:
{
"Version": "2012-10-17",
"Id": "Policy1591045332632",
"Statement": [
{
"Sid": "Stmt1618270933950",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::jpolara1-*/*"
},
{
"Sid": "Stmt1617806794444",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow",
"Resource": "arn:aws:logs:*:*:*"
}
]
}
- AWS Lambda fucntion copy_objects (Python3.8)
- AWS Lambda fucntion delete_objects (Python3.8)
- Configure Lambda Trigger for your functions