diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..e69de29 diff --git a/dotenv_to_ssm.py b/dotenv_to_ssm.py new file mode 100755 index 0000000..59e2f9c --- /dev/null +++ b/dotenv_to_ssm.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +from pathlib import Path +import textwrap + +import boto3 +import click +import dotenv + +client = boto3.client("ssm") + + +@click.command() +@click.argument("dotenv_file", type=click.Path(exists=True)) +@click.argument("prefix", type=click.Path()) +@click.option( + "--overwrite", + "Overwrite", + default=False, + help="Overwrite an existing parameter.", +) +@click.option( + "--type", + "Type", + default="SecureString", + type=click.Choice(["String", "StringList", "SecureString"], case_sensitive=False), + help="The type of parameter that you want to add to the system.", +) +def load(dotenv_file: click.Path, prefix: click.Path, **kwargs): + config = dotenv.dotenv_values(dotenv_file) + + print(prefix) + + for k, v in config.items(): + path = Path(prefix) / k.lower() + try: + client.put_parameter( + Name=str(path), + Description="Created by the dotenv-to-ssm script.", + Value=v, + Tags=[ + {"Key": "author", "Value": "string"}, + ], + **kwargs, + ) + print(f"Created {path}") + except Exception as e: + error_text = textwrap.indent(str(e), prefix="\t") + print(f"Failed to create {path}: \n{error_text}") + print(kwargs) + + +if __name__ == "__main__": + load() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7fd26b9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index fd9f0f2..6cd6e91 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,42 @@ +[metadata] +name = pydantic-ssm-settings +version = attr: src.VERSION +description = A Pydantic configuration provider for AWS SSM Parameter Store. +long_description = file: README.md +keywords = Pydantic, AWS, SSM, Parameter, Store +license = MIT +classifiers = + Intended Audience :: Developers + Intended Audience :: Information Technology + Intended Audience :: Science/Research + Programming Language :: Python :: 3.8 + License :: OSI Approved :: MIT License +url = https://github.com/developmentseed/pydantic-ssm-settings +author = Anthony Lukach +author_email = anthony@developmentseed.org + +[options] +zip_safe = False +include_package_data = True +packages = find: + +[options.packages.find] + +exclude = tests + +install_requires = + pydantic + +[options.entry_points] +console_scripts = + dotenv-to-ssm = dotenv_to_ssm:load [cli] + +[options.extras_require] +cli = + boto3 + click + python-dotenv + [tool:pytest] testpaths = tests addopts = -p no:hypothesispytest diff --git a/setup.py b/setup.py deleted file mode 100644 index 029e284..0000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -from setuptools import find_namespace_packages, setup - -with open("README.md") as f: - desc = f.read() - -setup( - name="pydantic-ssm-settings", - description="A Pydantic configuration provider for AWS SSM Parameter STore.", - long_description=desc, - long_description_content_type="text/markdown", - python_requires=">=3.8", - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "Programming Language :: Python :: 3.8", - "License :: OSI Approved :: MIT License", - ], - keywords="Pydantic AWS SSM Parameter Store", - author=u"Anthony Lukach", - author_email="anthony@developmentseed.rg", - url="https://github.com/stac-utils/stac-fastapi", - license="MIT", - packages=find_namespace_packages(exclude=["tests"]), - zip_safe=False, - install_requires=[ - "pydantic", - ], -) diff --git a/pydantic_ssm_settings/__init__.py b/src/__init__.py similarity index 81% rename from pydantic_ssm_settings/__init__.py rename to src/__init__.py index 5446b21..568e71a 100644 --- a/pydantic_ssm_settings/__init__.py +++ b/src/__init__.py @@ -1,3 +1,4 @@ from .settings import AwsSsmSourceConfig __all__ = ('AwsSsmSourceConfig',) +VERSION = '0.0.1' \ No newline at end of file diff --git a/pydantic_ssm_settings/settings.py b/src/settings.py similarity index 100% rename from pydantic_ssm_settings/settings.py rename to src/settings.py diff --git a/pydantic_ssm_settings/source.py b/src/source.py similarity index 100% rename from pydantic_ssm_settings/source.py rename to src/source.py diff --git a/pydantic_ssm_settings/ssm.py b/src/ssm.py similarity index 100% rename from pydantic_ssm_settings/ssm.py rename to src/ssm.py