-
Notifications
You must be signed in to change notification settings - Fork 1
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
[QOLSVC-8441] make SSM parameter retrieval more robust #484
Conversation
ThrawnCA
commented
Dec 3, 2024
- Retry up to 5 times if retrieval fails
- Provide fallback default value when appropriate
- Retry up to 5 times if retrieval fails - Provide fallback default value when appropriate
a147b6a
to
695856e
Compare
recipes/ckanweb-deploy-exts.rb
Outdated
egg_name = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/shortname" --query "Parameter.Value" --output text`.strip | ||
retries = 0 | ||
while retries < 5 | ||
egg_name = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/shortname" --query "Parameter.Value" --output text`.strip |
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.
can't we do a single ssm call and then pull apart the parts to their variables instead of lots of little calls.
i.e.
aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/
this will have shortname
, type
, url
, revision
which we can then pull part.
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.
Theoretically, yes. It would be messier since we would need to import the JSON module, use it to parse the get_parameters
result into a list, then iterate through that list checking "if Name is 'foo' then assign Value to foo, else if name is 'baz' then assign Value to baz, etc". But it could be done.
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.
you could try with ruby/json and decrypt the payload. or you could do with get-parameters --names "name1" "name2" "name3" --query "Parameters[*].[Name,Value]"
and split on name.
require 'json'
# Fetch all parameters in a single call
params = JSON.parse(`aws ssm get-parameters-by-path --region "#{node['datashades']['region']}" --path "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/app_source/" --query "Parameters[*].[Name,Value]" --output json`.strip)
# Convert the parameters into a hash for easier access
params_hash = params.each_with_object({}) do |(name, value), hash|
hash[name.split('/').last] = value
end
type = params_hash['type']
revision = params_hash['revision']
url = params_hash['url']
531bef2
to
41b01de
Compare
8067976
to
1a661db
Compare
- This should reduce API calls and be fractionally faster
1a661db
to
25aa1bf
Compare