Created
August 15, 2017 18:06
-
-
Save thatarchguy/773f5e6d5c4e8182f9e8218765264ad8 to your computer and use it in GitHub Desktop.
Convert AWS RDS Parameter Group to mysqld.conf
This file contains 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
# You should edit this script to your liking. In its current form, | |
# it will take an original mysqld.cnf and merge the rds parameters with it. | |
# Comment out that stuff and you can easily just print the rds config as "param = value". | |
import json | |
from ConfigParser import SafeConfigParser | |
# aws rds describe-db-parameters --db-parameter-group-name my-param-group > rds.json | |
with open('rds.json', 'r') as json_file: | |
data = json.load(json_file) | |
with open('mysqld.cnf', 'r') as conf_file: | |
config = SafeConfigParser() | |
config.read('mysqld.cnf') | |
config_dict = dict(config.items('mysqld')) | |
rds = {} | |
for item in data.get('Parameters'): | |
if item.get('ParameterValue'): | |
#print("{0} = {1}".format(item.get('ParameterName'), item.get('ParameterValue'))) | |
rds[item.get('ParameterName')] = item.get('ParameterValue') | |
#else: | |
#print("#{0}".format(item.get('ParameterName'))) | |
config_dict.update(rds) | |
#print(config_dict) | |
for k, v in config_dict.items(): | |
print("{0} = {1}".format(k, v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment