-
Notifications
You must be signed in to change notification settings - Fork 1
Multi line parameters #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
parameter_sync.py
Outdated
if 'Parameters' in result: | ||
parameter_list = result['Parameters'] | ||
for parameter_name in parameter_names_list: | ||
result = ssm.get_parameters(Names=[parameter_name], WithDecryption=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're only going to get one at a time, why not use get_parameter instead of get_parameters?
For the record, this seems to be WAY less efficient than sending a list of parameter names. If there is a limit to how many parameters you can put in the list (not documented, but clearly a problem) then why not break up the list in chunks of size X and call this method multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to get_parameter.
This is much less efficient, but the get_paramter call is very quick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you've tested this and it works, then approved.
As mentioned in the comment I made - the change you made to handle more than 10 parameters makes the code way less efficient.
@@ -47,7 +50,7 @@ def process_parameter(param_name, param_value): | |||
new_file_full_path = temp_dir + os.sep + filename + '.new' | |||
logging.debug('Storing retrieved value for parameter "%s" in "%s"' % (param_name, new_file_full_path)) | |||
with open(new_file_full_path, 'w') as f: | |||
f.write(param_value.replace('\\n', '\n')) | |||
f.write(param_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this should still work with files that did have unescaped new lines so that's good.
Updated to Python 3.8, don't do the newline replacement in text of secrets, and handle more than 10 secrets.