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
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import enum
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
@ -28,6 +29,12 @@ class SSMPath(pathlib.PurePosixPath):
|
||||||
return SSMPath(value)
|
return SSMPath(value)
|
||||||
|
|
||||||
|
|
||||||
|
class SSMParameterType(str, enum.Enum):
|
||||||
|
String = "String"
|
||||||
|
SecureString = "SecureString"
|
||||||
|
StringList = "StringList"
|
||||||
|
|
||||||
|
|
||||||
ProfileArg = typing.Annotated[str, typer.Argument(autocompletion=lambda: aws_profiles)]
|
ProfileArg = typing.Annotated[str, typer.Argument(autocompletion=lambda: aws_profiles)]
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +110,7 @@ def list_parameters(
|
||||||
def set(
|
def set(
|
||||||
profile: ProfileArg,
|
profile: ProfileArg,
|
||||||
path: str,
|
path: str,
|
||||||
value: str,
|
values: list[str],
|
||||||
secure: bool = False,
|
secure: bool = False,
|
||||||
overwrite: bool = False,
|
overwrite: bool = False,
|
||||||
description: typing.Annotated[str, typer.Option] = "",
|
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 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)
|
client = get_client(profile)
|
||||||
try:
|
try:
|
||||||
client.put_parameter(
|
client.put_parameter(
|
||||||
Name=str(SSMPath(path)),
|
Name=str(SSMPath(path)),
|
||||||
Value=value,
|
Value=value,
|
||||||
Type="SecureString" if secure else "String",
|
Type=parameter_type.value,
|
||||||
Overwrite=overwrite,
|
Overwrite=overwrite,
|
||||||
Description=description,
|
Description=description,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue