Skip to content

Commit

Permalink
Merge pull request #185 from awslabs/v1m2m0
Browse files Browse the repository at this point in the history
v1.2.0 release
  • Loading branch information
dlpzx authored Nov 3, 2022
2 parents a951b8e + 1beb991 commit 4ecfd0f
Show file tree
Hide file tree
Showing 132 changed files with 7,249 additions and 2,147 deletions.
169 changes: 169 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/


# VSCode extension
.vscode/
/.favorites.json
*.code-workspace

# TypeScript incremental build states
*.tsbuildinfo

# Local state files & OS specifics
.DS_Store
node_modules/
lerna-debug.log
dist/
pack/
.BUILD_COMPLETED
.local-npm/
.tools/
coverage/
.nyc_output
.LAST_BUILD
*.sw[a-z]
*~
.idea

# We don't want tsconfig at the root
/tsconfig.json

# Backed up json files
*.json-e

# CDK Context & Staging files
cdk.context.json
.cdk.staging/
cdk.out/
.out

# DDK Context & Staging files
.ddk.out/
37 changes: 37 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# !/usr/bin/env python3

import aws_cdk as cdk
from aws_ddk_core.cicd import CICDPipelineStack
from ddk_app.ddk_app_stack import DDKApplicationStack
from aws_ddk_core.config import Config

app = cdk.App()

class ApplicationStage(cdk.Stage):
def __init__(
self,
scope,
environment_id: str,
**kwargs,
) -> None:
super().__init__(scope, f"dataall-{environment_id.title()}", **kwargs)
DDKApplicationStack(self, "DataPipeline-PIPELINENAME-PIPELINEURI", environment_id)

config = Config()
(
CICDPipelineStack(
app,
id="dataall-pipeline-PIPELINENAME-PIPELINEURI",
environment_id="cicd",
pipeline_name="PIPELINENAME",
)
.add_source_action(repository_name="dataall-PIPELINENAME-PIPELINEURI")
.add_synth_action()
.build().add_stage("dev", ApplicationStage(app, "dev", env=config.get_env("dev"))).add_stage("prod", ApplicationStage(app, "prod", env=config.get_env("prod")))
.synth()
)

app.synth()


30 changes: 30 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"app": "python3 app.py",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"requirements*.txt",
"source.bat",
"**/__init__.py",
"python/__pycache__",
"tests"
]
},
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:stackRelativeExports": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
]
}
}
22 changes: 22 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/ddk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"environments": {
"cicd": {
"account": "111111111111",
"region": "eu-west-1"
},
"dev": {
"account": "222222222222",
"region": "eu-west-1",
"resources": {
"ddk-bucket": {"versioned": false, "removal_policy": "destroy"}
}
},
"prod": {
"account": "333333333333",
"region": "eu-west-1",
"resources": {
"ddk-bucket": {"versioned": true, "removal_policy": "retain"}
}
}
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import Any

from aws_ddk_core.base import BaseStack
from constructs import Construct


class DDKApplicationStack(BaseStack):

def __init__(self, scope: Construct, id: str, environment_id: str, **kwargs: Any) -> None:
super().__init__(scope, id, environment_id, **kwargs)

# The code that defines your stack goes here:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==6.2.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
aws-cdk-lib==2.20.0
constructs>=10.0.0,<11.0.0
aws_ddk_core==0.3.1
30 changes: 30 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import setuptools

with open("README.md") as fp:
long_description = fp.read()


setuptools.setup(
name="sample-app",
version="0.3.1",
description="An empty DDK Python app",
long_description=long_description,
long_description_content_type="text/markdown",
author="author",
package_dir={"": "sample-app"},
packages=setuptools.find_packages(where="sample-app"),
install_requires=open("requirements.txt").read().strip().split("\n"),
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"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",
],
)
13 changes: 13 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/source.bat
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions backend/blueprints/cdk_data_pipeline_blueprint/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

# call tests for your code below

# pytest tests/unit/my_test.py
25 changes: 25 additions & 0 deletions backend/blueprints/data_pipeline_blueprint/app_multiaccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
import os
import aws_cdk as cdk
from aws_cdk import Tags
from ddk_app.ddk_app_stack import DdkApplicationStack

from utils.config import MultiaccountConfig

stage_id = os.environ.get('STAGE', None)
pipeline_name = os.environ.get('PIPELINE_NAME')

app = cdk.App()

config = MultiaccountConfig()
environment_id = config.get_stage_env_id(stage_id)
env_vars = config.get_env_var_config(environment_id)['env_vars']

Tags.of(app).add("dataall", "true")
Tags.of(app).add("Target", pipeline_name)
DdkApplicationStack(app,
f"{pipeline_name}-DdkApplicationStack",
environment_id,
env_vars)

app.synth()
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Any, Optional

from aws_cdk import Environment, Tags
from aws_ddk_core.base import BaseStack
from aws_ddk_core.config import Config
from constructs import Construct


class DdkApplicationStack(BaseStack):


def __init__(self, scope: Construct,
id: str,
environment_id: str,
env_vars: dict,
env: Optional[Environment] = None,
**kwargs: Any) -> None:
self._config = Config()
super().__init__(
scope,
id,
environment_id=environment_id,
env=env or self._config.get_env(environment_id),
**kwargs)

Tags.of(self).add("Team", str(env_vars['Team']))

# The code that defines your stack goes here:
Loading

0 comments on commit 4ecfd0f

Please sign in to comment.