Add support for setting string lists
This commit is contained in:
parent
4b3ddd9369
commit
26c1eb5bf4
1 changed files with 16 additions and 2 deletions
18
ssm.py
18
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,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue