Skip to content

Instantly share code, notes, and snippets.

@duttonw
Created June 6, 2024 23:11
Show Gist options
  • Save duttonw/1e6c11dccfb88827b707289b21d2af38 to your computer and use it in GitHub Desktop.
Save duttonw/1e6c11dccfb88827b707289b21d2af38 to your computer and use it in GitHub Desktop.
AWs Param Store batch lost secrets with helper function (with example)
#!/bin/bash
# Function to set or update a parameter in AWS Parameter Store
set_parameter() {
local PARAM_NAME=$1
local PARAM_VALUE=$2
local IS_SECRET=${3:-false} # Default false, set to true for secret (encrypted) parameters
# Determine the parameter type
if [ "$IS_SECRET" = true ]; then
PARAM_TYPE="SecureString"
else
PARAM_TYPE="String"
fi
# Create or update the parameter
echo "Setting parameter $PARAM_NAME..."
aws ssm put-parameter --name "$PARAM_NAME" --value "$PARAM_VALUE" --type "$PARAM_TYPE" --overwrite
}
set_parameter "example_param_1" "value1"
set_parameter "example_param_2" "super secret value" true #this one is encrypted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment