Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 254
Igor L. Avatar asked Feb 20 '19 13:02

Igor L.


2 Answers

  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"`);
}
like image 130
Igor L. Avatar answered Sep 20 '22 14:09

Igor L.


Here is my version that outputs all parameters' Name, Type and Value in a TSV (tab-separated values) format:

aws ssm get-parameters-by-path --path "/" --recursive --query="Parameters[*].[Name, Type, Value]" --output text

Example response:

/prod/aaa    String  xxx
/prod/bbb    String  yyy
/prod/ccc    String  zzz
like image 41
Vlad Holubiev Avatar answered Sep 18 '22 14:09

Vlad Holubiev