Giter Club home page Giter Club logo

parameter-store-replicator's Introduction

parameter-store-replicator

AWS Systems Manager Parameter Store cross-region replicator

Overview

This Lambda function is designed to replicate parameters stored in the AWS Systems Manager Parameter Store across different regions within the same AWS account. It listens for CloudWatch events and replicates any updated parameters to a specified target region immediately.

Installation

Ensure that you have the Serverless Framework installed:

npm install -g serverless

Deploy the Lambda function to your main region, setting the target as your replication region. For example, to replicate from us-east-1 to us-west-2:

sls deploy --source_region us-east-1 --target_region us-west-2

Establish two-way replication by deploying a counterpart Lambda in the target region:

sls deploy --source_region us-west-2 --target_region us-east-1

Note: To prevent infinite loops in two-way replication setups (the "ping pong" effect), logic is implemented to check if the parameter's value and type match in the target region. If they do, the replication is skipped.

Testing

Deploy your function with the updated settings, then update a parameter in your main region:

aws ssm put-parameter --name "/example/parameter" --value "newValue" --type "String" --overwrite --region us-east-1

After a short wait, you should see the parameter replicated in the target region. Verify by retrieving the parameter in both regions:

aws ssm get-parameter --name "/example/parameter" --region us-east-1

Expected output from us-east-1:

{
    "Parameter": {
        "Version": [Latest_Version_Number], 
        "Type": "String", 
        "Name": "/example/parameter", 
        "Value": "newValue"
    }
}
aws ssm get-parameter --name "/example/parameter" --region us-west-2

Expected output from us-west-2:

{
    "Parameter": {
        "Version": [Latest_Version_Number], 
        "Type": "String", 
        "Name": "/example/parameter", 
        "Value": "newValue"
    }
}

Retroactive Replication Script

In instances where the parameter-store-replicator Lambda has been non-operational, we provide a Python script for manual, retroactive replication of parameters not copied during the downtime.

  • Purpose: Facilitates the retroactive replication of parameters missed during Lambda downtime.
  • Features:
    • Dry-run mode to assess potential changes.
    • Skips and logs parameters that exceed size limits.
  • Usage:
    • Dry-Run Execution: Preview which parameters will be replicated without making changes.
      python replicate_parameters.py --source-region us-east-1 --target-region us-west-2 --dry-run
    • Actual Replication: Perform the replication of parameters.
      python replicate_parameters.py --source-region us-east-1 --target-region us-west-2

Please note that this script is intended as a stopgap measure and does not replace the real-time replication capabilities of the parameter-store-replicator Lambda function.

parameter-store-replicator's People

Contributors

jonasoneves avatar alessandrobologna avatar zswanson avatar dependabot-preview[bot] avatar larrybetson avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.