From e9b3da09f700b80c7112f6e2a9e4660e2440675a Mon Sep 17 00:00:00 2001 From: Mystique <13oct08@quantumfoam.uni.cc> Date: Fri, 19 Feb 2021 15:36:56 +0100 Subject: [PATCH] Initial commit --- .gitignore | 11 ++++ README.md | 58 +++++++++++++++++++ app.py | 11 ++++ cdk.json | 12 ++++ requirements.txt | 1 + serverless_api_mutual_tls/__init__.py | 0 .../serverless_api_mutual_tls_stack.py | 9 +++ setup.py | 45 ++++++++++++++ source.bat | 13 +++++ 9 files changed, 160 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app.py create mode 100644 cdk.json create mode 100644 requirements.txt create mode 100644 serverless_api_mutual_tls/__init__.py create mode 100644 serverless_api_mutual_tls/serverless_api_mutual_tls_stack.py create mode 100644 setup.py create mode 100644 source.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58505a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.swp +package-lock.json +__pycache__ +.pytest_cache +.env +.venv +*.egg-info + +# CDK asset staging directory +.cdk.staging +cdk.out diff --git a/README.md b/README.md new file mode 100644 index 0000000..17cb0bb --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ + +# Welcome to your CDK Python project! + +This is a blank project for Python development with CDK. + +The `cdk.json` file tells the CDK Toolkit how to execute your app. + +This project is set up like a standard Python project. The initialization +process also creates a virtualenv within this project, stored under the `.venv` +directory. To create the virtualenv it assumes that there is a `python3` +(or `python` for Windows) executable in your path with access to the `venv` +package. If for any reason the automatic creation of the virtualenv fails, +you can create the virtualenv manually. + +To manually create a virtualenv on MacOS and Linux: + +``` +$ python3 -m venv .venv +``` + +After the init process completes and the virtualenv is created, you can use the following +step to activate your virtualenv. + +``` +$ source .venv/bin/activate +``` + +If you are a Windows platform, you would activate the virtualenv like this: + +``` +% .venv\Scripts\activate.bat +``` + +Once the virtualenv is activated, you can install the required dependencies. + +``` +$ pip install -r requirements.txt +``` + +At this point you can now synthesize the CloudFormation template for this code. + +``` +$ cdk synth +``` + +To add additional dependencies, for example other CDK libraries, just add +them to your `setup.py` file and rerun the `pip install -r requirements.txt` +command. + +## Useful commands + + * `cdk ls` list all stacks in the app + * `cdk synth` emits the synthesized CloudFormation template + * `cdk deploy` deploy this stack to your default AWS account/region + * `cdk diff` compare deployed stack with current state + * `cdk docs` open CDK documentation + +Enjoy! diff --git a/app.py b/app.py new file mode 100644 index 0000000..2f44988 --- /dev/null +++ b/app.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +from aws_cdk import core + +from serverless_api_mutual_tls.serverless_api_mutual_tls_stack import ServerlessApiMutualTlsStack + + +app = core.App() +ServerlessApiMutualTlsStack(app, "serverless-api-mutual-tls") + +app.synth() diff --git a/cdk.json b/cdk.json new file mode 100644 index 0000000..552b09f --- /dev/null +++ b/cdk.json @@ -0,0 +1,12 @@ +{ + "app": "python3 app.py", + "context": { + "@aws-cdk/core:enableStackNameDuplicates": "true", + "aws-cdk:enableDiffNoFail": "true", + "@aws-cdk/core:stackRelativeExports": "true", + "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true, + "@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true, + "@aws-cdk/aws-kms:defaultKeyPolicies": true, + "@aws-cdk/aws-s3:grantWriteWithoutAcl": true + } +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d6e1198 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-e . diff --git a/serverless_api_mutual_tls/__init__.py b/serverless_api_mutual_tls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/serverless_api_mutual_tls/serverless_api_mutual_tls_stack.py b/serverless_api_mutual_tls/serverless_api_mutual_tls_stack.py new file mode 100644 index 0000000..654a848 --- /dev/null +++ b/serverless_api_mutual_tls/serverless_api_mutual_tls_stack.py @@ -0,0 +1,9 @@ +from aws_cdk import core + + +class ServerlessApiMutualTlsStack(core.Stack): + + def __init__(self, scope: core.Construct, construct_id: str, **kwargs) -> None: + super().__init__(scope, construct_id, **kwargs) + + # The code that defines your stack goes here diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..436c3e7 --- /dev/null +++ b/setup.py @@ -0,0 +1,45 @@ +import setuptools + + +with open("README.md") as fp: + long_description = fp.read() + + +setuptools.setup( + name="serverless_api_mutual_tls", + version="0.0.1", + + description="An empty CDK Python app", + long_description=long_description, + long_description_content_type="text/markdown", + + author="author", + + package_dir={"": "serverless_api_mutual_tls"}, + packages=setuptools.find_packages(where="serverless_api_mutual_tls"), + + install_requires=[ + "aws-cdk.core==1.89.0", + ], + + python_requires=">=3.6", + + classifiers=[ + "Development Status :: 4 - Beta", + + "Intended Audience :: Developers", + + "License :: OSI Approved :: Apache Software License", + + "Programming Language :: JavaScript", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + + "Topic :: Software Development :: Code Generators", + "Topic :: Utilities", + + "Typing :: Typed", + ], +) diff --git a/source.bat b/source.bat new file mode 100644 index 0000000..9e1a834 --- /dev/null +++ b/source.bat @@ -0,0 +1,13 @@ +@echo off + +rem The sole purpose of this script is to make the command +rem +rem source .venv/bin/activate +rem +rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows. +rem On Windows, this command just runs this batch file (the argument is ignored). +rem +rem Now we don't need to document a Windows command for activating a virtualenv. + +echo Executing .venv\Scripts\activate.bat for you +.venv\Scripts\activate.bat