Skip to content

Bug: parameters confusing is combining get_parameter and get_parameters results #2438

Closed
@beck3905

Description

@beck3905

Expected Behaviour

Given SSM parameters:

  • /foo/bar/param1
  • /foo/bar/param2
  • /foo/bar/param3

Calling parameters.get_parameters("/foo/bar") should return a dictionary of all 3 parameters.
Calling parameters.get_parameter("/foo/bar") should ALWAYS raise a GetParameterError. This error should be raised even if the get_parameter call comes after the get_parameters call.

Current Behaviour

Given the same parameters as above:

If I call parameters.get_parameters("/foo/bar") all 3 parameters are cached under the parameter /foo/bar and returned as a dictionary.
If I subsequently call parameters.get_parameter("/foo/bar") it returns the same dictionary as the get_parameters call instead of raising the GetParameterError.

Code snippet

# Update paths below to PATH of actual SSM parameters in your account and not parameter NAMES.


from aws_lambda_powertools.utilities import parameters

print(parameters.get_parameters(path="/foo/bar"))
print(parameters.get_parameter("/foo/bar"))

Possible Solution

  • Cache get_parameter results separately from get_parameters results.
  • Note in the cache whether the values being cached are from get_parameter or get_parameters.

Steps to Reproduce

  1. Add multiple SSM parameters to parameter store under the same path.
  2. Run Code Snippet above referencing the SSM parameters' path.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.9

Packaging format used

Lambda Layers

Debugging logs

No response

Metadata

Metadata

Labels

bugSomething isn't workingparametersParameters utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions