Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 29, 2015 14:07
Show Gist options
  • Save tkuchiki/7f6275a8c081ea9b91f3 to your computer and use it in GitHub Desktop.
Save tkuchiki/7f6275a8c081ea9b91f3 to your computer and use it in GitHub Desktop.
RDS の parameter groups の値を変更する
#!/bin/bash
usage() {
echo "Usage: $(basename $0) -g|--group PARAM -n|--name PARAM_NAME -v|--value PARAM_VALUE [-p|--pending-reboot]
-n|--name parameter name
-v|--value parameter value
-p|--pending-reboot set ApplyMethod=pending-reboot (default: immediate)
-g|--group set parameter group
-h|--help show this help message and exit
"
exit 0
}
OPT=$(getopt -q -o n:v:g:ph -l name:,value:,group:,pending-reboot,help -- "${@}")
eval set -- "${OPT}"
APPLY_METHOD="immediate"
PARAMETER_GROUP=""
while :; do
case "${1}" in
-g|--group) PARAM_GROUP="${2}"; shift 2 ;;
-n|--name) PARAM_NAME="${2}"; shift 2 ;;
-v|--value) PARAM_VALUE="${2}"; shift 2 ;;
-p|--pending-reboot) APPLY_METHOD="pending-reboot"; shift 1 ;;
-h|--help) usage ;;
--) shift; break ;;
*) echo "Internal error!" 1>&2; exit 1 ;;
esac
done
if [ "${PARAM_GROUP}" = "" -a "${PARAM_NAME}" = "" -a "${PARAM_VALUE}" = "" ]; then
usage
elif [ "${PARAM_GROUP}" = "" ]; then
echo "PARAM_GROUP is required."
exit 1
elif [ "${PARAM_NAME}" = "" ]; then
echo "PARAM_NAME is required."
exit 1
elif [ "${PARAM_VALUE}" = "" ]; then
echo "PARAM_VALUE is required."
exit 1
fi
# export AWS_CONFIG_FILE=/path/to/.aws/config
aws rds modify-db-parameter-group --db-parameter-group-name "${PARAM_GROUP}" \
--parameters ParameterName="${PARAM_NAME}",ParameterValue="${PARAM_VALUE}",ApplyMethod="${APPLY_METHOD}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment