Skip to content

alessandrobologna/parameter-store-replicator

Repository files navigation

parameter-store-replicator

AWS System Manager Parameter Store cross region replicator

What is this

This is a sample Lambda to replicate the variables stored in AWS System Manager Parameter Store across different regions, in the same account. It listes to CloudWatch events, and when a parameter is updated, it tries to replicate it to another target region as defined during deployment of the Lambda function. It supports two way replication, so you can deploy the same lambda in, say us-east-1 and us-west-2 specifying the other region as a replication target.

Installing it

The project depends on the serverless framework, so you will want to install that first:

$ npm install -g serverless

After you have it installed, just deploy your function to the main region, specifying as target the replication region. For instance, to replicate from us-east-1 to us-west-2:

$ sls deploy --region us-east-1  --target=us-west-2

You can establish two way replication by deploying the same lambda to the target region:

$ sls deploy --region us-west-2  --target=us-east-1

If you are using two way replication, there's logic in place to avoid the "ping pong" effect, where a region replicating to another causes the replication to happen in the other direction. Currenlty, the logic is just based on value and type for a given parameter. If they already exist in the target region, and their value match, replication is not performed.

Testing it

Just deploy the code, as described above, and run

$ aws ssm put-parameter --name "/root/test4" --value "test6" --type "String" --overwrite --region us-east-1

After a few seconds, you should be able to do (results included):

$ aws ssm get-parameter --name "/root/test4" --region us-east-1
{
    "Parameter": {
        "Version": 65, 
        "Type": "String", 
        "Name": "/root/test4", 
        "Value": "test6"
    }
}

$ aws ssm get-parameter --name "/root/test4" --region us-west-2
{
    "Parameter": {
        "Version": 14, 
        "Type": "String", 
        "Name": "/root/test4", 
        "Value": "test6"
    }

About

AWS System Manager Parameter Store cross region replicator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published