Work on TF module for AWS Secrets Manager(SM) replication.
- Secret is updated or created in original AWS Region.
- CloudTrail receives a log with “eventName”: “PutSecretValue” or "eventName" : "CreateSecret".
- CloudTrail passes this log to CloudWatch Events.
- A filter in CloudWatch Events for this EventName triggers a Lambda function.
- The Lambda function retrieves the secret value from the origin AWS Region.
- The Lambda function then performs PutSecretValue or CreateSecret on a secret with the same name in the replica AWS Region.
If secret encrypted with custom KMS key, key will be created in replica region with same name, description, tags and policy as in original region. Than secret will be created or updated with this KMS key.
Since module replicates secret on Event from SM, for initial replication you can run util/copy_all_secret.py. Look at README in util/
To start module run:
make S_REG='source_region=<your_source_region>' T_REG='target_region=<your_target_region>' plan/apply
Lambda function writes log in CloudTrail. So logs can be found in AWS Console Lambda->Functions->ReplicateSecretsToTargetRegion->Monitoring.