Skip to content

Commit

Permalink
adding support for path
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Nov 20, 2024
1 parent 31e9d2f commit 728f585
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def create(
return get_ssm_parameter_task.GetSSMParameterByPathTask(
**common_parameters,
path=parameters_to_use.get("path"),
jmespath_location=parameters_to_use.get("jmespath"),
)

elif section_name == constants.SSM_PARAMETERS:
Expand Down
10 changes: 9 additions & 1 deletion servicecatalog_puppet/workflow/ssm/get_ssm_parameter_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def params_for_results_display(self):
"account_id": self.account_id,
"region": self.region,
"param_name": self.param_name,
"jmespath_location": self.jmespath_location,
}

def get_parameter_name_to_use(self):
Expand Down Expand Up @@ -52,6 +53,7 @@ def run(self):
class GetSSMParameterByPathTask(tasks.TaskWithReference):
account_id = luigi.Parameter()
path = luigi.Parameter()
jmespath_location = luigi.Parameter()
region = luigi.Parameter()
cachable_level = constants.CACHE_LEVEL_RUN

Expand All @@ -61,6 +63,7 @@ def params_for_results_display(self):
"account_id": self.account_id,
"region": self.region,
"path": self.path,
"jmespath_location": self.jmespath_location,
}

def run(self):
Expand All @@ -71,7 +74,12 @@ def run(self):
Path=self.get_parameter_path_to_use(), Recursive=True
):
for parameter in page.get("Parameters", []):
parameters[parameter.get("Name")] = parameter
p = deepcopy(parameter)
if self.jmespath_location:
p["Value"] = jmespath.search(
self.jmespath_location, json.loads(p.get("Value"))
)
parameters[parameter.get("Name")] = p
self.write_output(parameters)

def get_parameter_path_to_use(self):
Expand Down

0 comments on commit 728f585

Please sign in to comment.