amazon-web-servicesaws-lambdaaws-documentdbaws-backup

How to use an AWS Restore job to a trigger Lambda function


I have a DocumentDB cluster backed up using AWS Backup. When I restore it, it just creates a cluster with no instances and the cluster uses the default security group of the VPC.

I could not find any solution to fix this as part of the restore job. So, I am using a lambda function that uses boto3 to update the security group and add instances to the cluster.

Now is it possible to trigger the Lambda function automatically when the restore job is completed?


Solution

  • When your Backup job finishes, you can capture an event using EventBridge and then trigger your Lambda off of that.

    This blog post from AWS covers triggering a Lambda off the back of an AWS Backup job using EventBridge. It's not the exact same scenario since they're triggering the Lambda from the Backup AND Restore jobs, but you should be able to extract the steps you need from that.