Skip to content

Instantly share code, notes, and snippets.

@bboure
Last active December 11, 2023 11:40
Show Gist options
  • Save bboure/10a084ca30d442eae8ea6b622171681e to your computer and use it in GitHub Desktop.
Save bboure/10a084ca30d442eae8ea6b622171681e to your computer and use it in GitHub Desktop.
Delete SSM parameters by path prefix
aws ssm get-parameters-by-path --path '/path/to/prams' --recursive \
| jq .Parameters[].Name \
| xargs -L1 -I'{}' aws ssm delete-parameter --name {}
@avivka
Copy link

avivka commented May 11, 2022

aws ssm get-parameters-by-path --path '/path/to/prams' --recursive \ | jq '.Parameters[].Name' \ | xargs -L1 -I'{}' aws ssm delete-parameter --name {}
(with '' on the jq command) worked for me

@egarbi
Copy link

egarbi commented Dec 11, 2023

This doesn't require jq to be installed, also adding -t helps to see what are you actually deleting

aws ssm get-parameters-by-path --path '/path/to/prams' --recursive --query 'Parameters[].Name' \
xargs -t -L1 -I'{}' aws ssm delete-parameter --name {}

Tip

Better to use a role or user with restricted by-path permissions to avoid removing undesired keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment