Skip to content

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

Merged
merged 3 commits into from
Jan 8, 2020
Merged

Multi line parameters #2

merged 3 commits into from
Jan 8, 2020

Conversation

ryan-j-mci
Copy link
Contributor

Updated to Python 3.8, don't do the newline replacement in text of secrets, and handle more than 10 secrets.

if 'Parameters' in result:
parameter_list = result['Parameters']
for parameter_name in parameter_names_list:
result = ssm.get_parameters(Names=[parameter_name], WithDecryption=True)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@haggaret haggaret left a 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)
Copy link
Member

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.

@ryan-j-mci ryan-j-mci merged commit f180bfc into master Jan 8, 2020
@ryan-j-mci ryan-j-mci deleted the multi-line-parameters branch January 8, 2020 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants