diff --git a/ssm.py b/ssm.py index d8649bc..ee7d618 100644 --- a/ssm.py +++ b/ssm.py @@ -1,5 +1,6 @@ from __future__ import annotations +import enum import os import pathlib import sys @@ -28,6 +29,12 @@ class SSMPath(pathlib.PurePosixPath): return SSMPath(value) +class SSMParameterType(str, enum.Enum): + String = "String" + SecureString = "SecureString" + StringList = "StringList" + + ProfileArg = typing.Annotated[str, typer.Argument(autocompletion=lambda: aws_profiles)] @@ -103,7 +110,7 @@ def list_parameters( def set( profile: ProfileArg, path: str, - value: str, + values: list[str], secure: bool = False, overwrite: bool = False, description: typing.Annotated[str, typer.Option] = "", @@ -112,12 +119,19 @@ def set( If --secure is used, it will be stored as a SecureString. """ + if secure: + parameter_type = SSMParameterType.SecureString + elif len(values) > 1: + parameter_type = SSMParameterType.StringList + else: + parameter_type = SSMParameterType.String + value: str = ",".join(values) client = get_client(profile) try: client.put_parameter( Name=str(SSMPath(path)), Value=value, - Type="SecureString" if secure else "String", + Type=parameter_type.value, Overwrite=overwrite, Description=description, )