Last active
October 30, 2024 16:51
-
-
Save bboure/10a084ca30d442eae8ea6b622171681e to your computer and use it in GitHub Desktop.
Delete SSM parameters by path prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ssm get-parameters-by-path --path '/path/to/prams' --recursive \ | |
| jq .Parameters[].Name \ | |
| xargs -L1 -I'{}' aws ssm delete-parameter --name {} |
#!/bin/bash
AWS_REGION=""
PATH=""
PARAMETERS_FOR_REMOVE=$(aws ssm get-parameters-by-path --region $AWS_REGION --path "$PATH" --recursive --output text --query "Parameters[].Name")
echo $PARAMETERS_FOR_REMOVE
for PARAMETER in ${PARAMETERS_FOR_REMOVE[]}; do
echo $PARAMETER
echo $PARAMETER >> $PATH.txt
aws ssm delete-parameter --region $AWS_REGION --name $PARAMETER
done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aws ssm get-parameters-by-path --path '/path/to/prams' --recursive --query 'Parameters[].Name' --output text | tr '\t' '\n' | xargs -t -I'{}' aws ssm delete-parameter --name {}