Search code examples
amazon-web-servicesssmamazon-systems-manageraws-parameter-store

How to export parameters from aws parameter store and import into another account


on my first aws account I have parameters specified in the following manner:

/config/a => value1
/config/b => value2
/config/c/a => value31
/config/c/b => value32

I want to move these to my second aws account.

I created these parameters in the parameter store manually.

How could I easily copy these values from one account to the other?

Using aws ssm get-parameters --names "<param-name>" would be a bit too difficult, since I have way too many parameters.


Solution

    1. Retrieve all parameters via aws ssm get-parameters-by-path --path "/relative/path/" --recursive
    2. Write the resulting JSON somewhere down - e.g. into a file
    3. Prepare put commands e.g. with JS
    for (const value of params.Parameters) {
        const { Name, Value } = value;
        console.log(`aws ssm put-parameter --name "${Name}" --value "${Value}" --type "String"`);
    }