SSM is indebted to me both publicly and privately, but I had a hard time with the command each time, so I chose alias. To be precise, I had to use an argument, so I implemented it as a function instead of an alias. It can be used as follows.
$ setssm TEST_KEY test_val #Register
$ getssm TEST_KEY #refer
test_val #output
$ setssm TEST_KEY2 "test space Japanese" #Space and Japanese processing is also possible
$ echo HOGE$(getssm TEST_KEY2)FUGA #Can be expanded on a command and handled as a variable
HOGEtest space Japanese FUGA
$ listssm | grep TEST #Search with grep from the output of the list and output the key and value including TEST
TEST_KEY test_val
TEST_KEY2 test space Japanese
The implementation just adds the following to the end of ~ / .bash_profile
and updates with source ~ / .bash_profile
.
~/.bash_profile
function setssm() {
command aws ssm put-parameter --name $1 --type "String" --overwrite --value "$2";
}
function getssm() {
command aws ssm get-parameter --name $1 --query 'Parameter.Value' --output text;
}
function listssm() {
command aws ssm get-parameters-by-path --path "/" --query "Parameters[].[Name,Value]" --output text
}
Personally, the best thing to do is to separate the commands for your company and for yourself.setssm_private
Whensetssm_corp
Prepare 2 patterns of commands such as--profile引数をそれぞれに付与するWhenパーソナルな情報を会社のssmにアップしたりその逆を避けれます。
Recently, the number of frameworks that can handle authentication information via SSM has increased, and it would be nice to eliminate the risk and worry of uploading authentication information to the repository. Have a good AWS life.
reference https://github.com/aws/aws-cli/issues/1961 https://hacknote.jp/archives/8043/ https://dev.classmethod.jp/articles/aws-cli-all-ssm-parameter-get/ https://qiita.com/tomoya_oka/items/a3dd44879eea0d1e3ef5
Recommended Posts