Skip to content

SSM

ssm_params(path)

Parameters:

Name Type Description Default
path str

The path in ssm to search for parameters in (i.e. /iam/live/)

required

Returns:

Type Description
dict

dict of paramters from the given path

Source code in delta_utils/ssm.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def ssm_params(path: str) -> dict:
    """
    Args:
        path (str): The path in ssm to search for parameters in (i.e. /iam/live/)

    Returns:
        dict of paramters from the given path
    """

    ssm = boto3.client("ssm", region_name=AWS_REGION)
    results = {}
    if not path.endswith("/"):
        path += "/"
    kwargs = {"Path": path, "Recursive": True, "WithDecryption": True}

    while True:
        response = ssm.get_parameters_by_path(**kwargs)

        for parameter in response["Parameters"]:
            env_name = parameter["Name"][len(path) :]
            env_value = parameter["Value"]
            results[env_name] = env_value

        if response.get("NextToken"):
            kwargs["NextToken"] = response["NextToken"]
            continue
        break
    return results