From 17017a1f84bfac45e0e61a32287802ac36e08e0a Mon Sep 17 00:00:00 2001 From: Domenico Testa Date: Tue, 14 Apr 2020 12:18:24 +0200 Subject: [PATCH] Initial commit --- .gitignore | 10 +++++ README.md | 58 ++++++++++++++++++++++++++++ app.py | 11 ++++++ cdk.json | 7 ++++ karaokeme_cdk/__init__.py | 0 karaokeme_cdk/karaokeme_cdk_stack.py | 9 +++++ requirements.txt | 1 + setup.py | 45 +++++++++++++++++++++ source.bat | 13 +++++++ 9 files changed, 154 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app.py create mode 100644 cdk.json create mode 100644 karaokeme_cdk/__init__.py create mode 100644 karaokeme_cdk/karaokeme_cdk_stack.py create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 source.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..383cdd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.swp +package-lock.json +__pycache__ +.pytest_cache +.env +*.egg-info + +# CDK asset staging directory +.cdk.staging +cdk.out diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d9d723 --- /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 .env +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 .env +``` + +After the init process completes and the virtualenv is created, you can use the following +step to activate your virtualenv. + +``` +$ source .env/bin/activate +``` + +If you are a Windows platform, you would activate the virtualenv like this: + +``` +% .env\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..03c5d54 --- /dev/null +++ b/app.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +from aws_cdk import core + +from karaokeme_cdk.karaokeme_cdk_stack import KaraokemeCdkStack + + +app = core.App() +KaraokemeCdkStack(app, "karaokeme-cdk") + +app.synth() diff --git a/cdk.json b/cdk.json new file mode 100644 index 0000000..39c301c --- /dev/null +++ b/cdk.json @@ -0,0 +1,7 @@ +{ + "app": "python3 app.py", + "context": { + "@aws-cdk/core:enableStackNameDuplicates": "true", + "aws-cdk:enableDiffNoFail": "true" + } +} diff --git a/karaokeme_cdk/__init__.py b/karaokeme_cdk/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/karaokeme_cdk/karaokeme_cdk_stack.py b/karaokeme_cdk/karaokeme_cdk_stack.py new file mode 100644 index 0000000..dc8abe5 --- /dev/null +++ b/karaokeme_cdk/karaokeme_cdk_stack.py @@ -0,0 +1,9 @@ +from aws_cdk import core + + +class KaraokemeCdkStack(core.Stack): + + def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: + super().__init__(scope, id, **kwargs) + + # The code that defines your stack goes here 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/setup.py b/setup.py new file mode 100644 index 0000000..e4cf65b --- /dev/null +++ b/setup.py @@ -0,0 +1,45 @@ +import setuptools + + +with open("README.md") as fp: + long_description = fp.read() + + +setuptools.setup( + name="karaokeme_cdk", + version="0.0.1", + + description="An empty CDK Python app", + long_description=long_description, + long_description_content_type="text/markdown", + + author="author", + + package_dir={"": "karaokeme_cdk"}, + packages=setuptools.find_packages(where="karaokeme_cdk"), + + install_requires=[ + "aws-cdk.core==1.32.2", + ], + + 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..8f57442 --- /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 .env/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 .env\Scripts\activate.bat for you +.env\Scripts\activate.bat