Skip to content
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

[PR #1756/c535e630 backport][stable-8] Create droppath option in ssm_parameter.py #2274

Commits on Aug 30, 2024

  1. Create droppath option in ssm_parameter.py (#1756)

    SUMMARY
    In the event that there exists two parameters in Parameter Store path/to/params/foo/bar/param and path/to/params/x/y/param, a user attempting to recursively pull all parameters under the path/to/params path with the command {{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}" will be unable to use the shortnames argument without creating a conflict between the two param results.  Only one param key will exist in the resulting dictionary.
    This is problematic for users that wish to lookup a parameter hierarchy with repetitive names in the final value of the parameter path. In this scenario, users are currently forced to use the fully qualified parameter name when interacting with their dictionary results.
    This pull request introduces the droppath option,  which will drop the common lookup path from the names of all parameters. In the scenario above, the resulting dictionary would contain both a foo/bar/param and a /x/y/param  allowing users to refer to them by their minimally differentiated name.
    ISSUE TYPE
    
    Feature Pull Request
    
    COMPONENT NAME
    
    lookup
    
    ADDITIONAL INFORMATION
    Step by step
    Setup
    
    Create parameter path/to/params/foo/bar/param with value abc
    Create parameter path/to/params/x/y/param with value 123
    
    Run shortnames
    
    name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param)
    debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}"
    
    Observe result  {'param': '123'}
    
    Run droppath
    
    name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param)
    debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, bypath=true, recursive=true ) }}"
    
    Observe result  {'/foo/bar/param': 'abc', '/x/y/param': '123'}
    
    Run both
    
    name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param)
    debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, shortnames = true, bypath=true, recursive=true ) }}"
    
    Observe error shortnames and droppath are mutually exclusive. They cannot both be set to true.
    
    Reviewed-by: Mark Chappell
    (cherry picked from commit c535e63)
    jacobcrell authored and patchback[bot] committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    5f6a502 View commit details
    Browse the repository at this point in the history