cdk-factory 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cdk_factory-0.0.1/.gitignore +178 -0
- cdk_factory-0.0.1/.vscode/launch.json +83 -0
- cdk_factory-0.0.1/.vscode/settings.json +29 -0
- cdk_factory-0.0.1/LICENSE +21 -0
- cdk_factory-0.0.1/PKG-INFO +19 -0
- cdk_factory-0.0.1/README.md +2 -0
- cdk_factory-0.0.1/devops/build.py +118 -0
- cdk_factory-0.0.1/devops/readme.md +23 -0
- cdk_factory-0.0.1/examples/website/README.md +8 -0
- cdk_factory-0.0.1/examples/website/static_website/README.md +6 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/__paths__.py +12 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/app.py +62 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/cdk.json +64 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/commands/cdk_synth.sh +40 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/config.json +137 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/requirements.txt +0 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/stacks/ecr_stack.py +60 -0
- cdk_factory-0.0.1/examples/website/static_website/devops/stacks/stacks.py +44 -0
- cdk_factory-0.0.1/examples/website/static_website/pyproject.toml +29 -0
- cdk_factory-0.0.1/examples/website/static_website/requirements.txt +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/readme.md +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/403.html +14 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/404.html +16 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/assets/img/geekcafe-56377c-lg.png +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/assets/img/geekcafe-f48024-lg.png +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/assets/img/geekcafe-f48024-sm.png +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/favicon.ico +0 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/index.html +16 -0
- cdk_factory-0.0.1/examples/website/static_website/src/www/version.txt +1 -0
- cdk_factory-0.0.1/mypy.ini +18 -0
- cdk_factory-0.0.1/pyproject.toml +33 -0
- cdk_factory-0.0.1/requirements-dev.txt +23 -0
- cdk_factory-0.0.1/run-checks.sh +4 -0
- cdk_factory-0.0.1/run_unit_tests.sh +22 -0
- cdk_factory-0.0.1/src/cdk_factory/__init__.py +1 -0
- cdk_factory-0.0.1/src/cdk_factory/__paths__.py +9 -0
- cdk_factory-0.0.1/src/cdk_factory/app.py +75 -0
- cdk_factory-0.0.1/src/cdk_factory/cdk.json +64 -0
- cdk_factory-0.0.1/src/cdk_factory/commands/command_loader.py +96 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/deployment.py +650 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/deployment_wave.py +6 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/devops.py +79 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/management.py +56 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/pipeline.py +168 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/pipeline_stage.py +101 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/_resources.py +77 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/apigateway.py +58 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/cloudfront.py +32 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/cloudwatch_widget.py +46 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/code_repository.py +56 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/cognito.py +61 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/docker.py +64 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/dynamodb.py +91 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/ecr.py +96 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/exisiting.py +19 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/lambda_function.py +421 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/lambda_layers.py +22 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/lambda_triggers.py +21 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/resource_mapping.py +56 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/resource_naming.py +105 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/resource_types.py +21 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/route53_hosted_zone.py +34 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/s3.py +175 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/resources/sqs.py +153 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/stack.py +75 -0
- cdk_factory-0.0.1/src/cdk_factory/configurations/workload.py +224 -0
- cdk_factory-0.0.1/src/cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py +266 -0
- cdk_factory-0.0.1/src/cdk_factory/constructs/s3_buckets/s3_bucket_construct.py +91 -0
- cdk_factory-0.0.1/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_destination_construct.py +73 -0
- cdk_factory-0.0.1/src/cdk_factory/constructs/s3_buckets/s3_bucket_replication_source_construct.py +117 -0
- cdk_factory-0.0.1/src/cdk_factory/pipeline/pipeline_factory.py +269 -0
- cdk_factory-0.0.1/src/cdk_factory/pipeline/security/policies.py +119 -0
- cdk_factory-0.0.1/src/cdk_factory/pipeline/security/roles.py +137 -0
- cdk_factory-0.0.1/src/cdk_factory/pipeline/stage.py +20 -0
- cdk_factory-0.0.1/src/cdk_factory/stack/istack.py +49 -0
- cdk_factory-0.0.1/src/cdk_factory/stack/stack_factory.py +36 -0
- cdk_factory-0.0.1/src/cdk_factory/stack/stack_module_loader.py +44 -0
- cdk_factory-0.0.1/src/cdk_factory/stack/stack_module_registry.py +19 -0
- cdk_factory-0.0.1/src/cdk_factory/stack/stack_modules.py +30 -0
- cdk_factory-0.0.1/src/cdk_factory/stacks/__init__.py +26 -0
- cdk_factory-0.0.1/src/cdk_factory/stacks/buckets/README.md +4 -0
- cdk_factory-0.0.1/src/cdk_factory/stacks/buckets/bucket_stack.py +60 -0
- cdk_factory-0.0.1/src/cdk_factory/stacks/websites/static_website_stack.py +244 -0
- cdk_factory-0.0.1/src/cdk_factory/stages/websites/static_website_stage.py +31 -0
- cdk_factory-0.0.1/src/cdk_factory/utilities/commandline_args.py +85 -0
- cdk_factory-0.0.1/src/cdk_factory/utilities/git_utilities.py +58 -0
- cdk_factory-0.0.1/src/cdk_factory/utilities/json_utility.py +148 -0
- cdk_factory-0.0.1/src/cdk_factory/utilities/os_execute.py +32 -0
- cdk_factory-0.0.1/src/cdk_factory/version.py +1 -0
- cdk_factory-0.0.1/src/cdk_factory/workload/workload_factory.py +140 -0
- cdk_factory-0.0.1/src/requirements.txt +4 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# PyPI configuration file
|
|
171
|
+
.pypirc
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# aws cdk ignores
|
|
175
|
+
cdk.out
|
|
176
|
+
|
|
177
|
+
# mac os file
|
|
178
|
+
.DS_store
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Python Debugger: Current File",
|
|
9
|
+
"type": "debugpy",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"program": "${file}",
|
|
12
|
+
"console": "integratedTerminal",
|
|
13
|
+
"justMyCode": true,
|
|
14
|
+
"env": {
|
|
15
|
+
|
|
16
|
+
"ENVRIONMENT": "dev",
|
|
17
|
+
"DEBUG_MODE": "True",
|
|
18
|
+
"PYTHONPATH": "${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/src/cdk_factory",
|
|
19
|
+
"RUN_INTEGRATION_TESTS": "True"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "CDK Synth with Python Args",
|
|
26
|
+
"type": "debugpy",
|
|
27
|
+
"request": "launch",
|
|
28
|
+
"program": "${workspaceFolder}/src/cdk_factory/app.py",
|
|
29
|
+
"console": "integratedTerminal",
|
|
30
|
+
"args": ["-c", "config=path/to/config.json"],
|
|
31
|
+
"env": {
|
|
32
|
+
|
|
33
|
+
"ENVRIONMENT": "dev",
|
|
34
|
+
"DEBUG_MODE": "True",
|
|
35
|
+
"PYTHONPATH": "${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/src/cdk_factory",
|
|
36
|
+
"RUN_INTEGRATION_TESTS": "True"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "CDK Synth with CDK Args",
|
|
41
|
+
"type": "node",
|
|
42
|
+
"request": "launch",
|
|
43
|
+
"program": "/Users/eric.wilson/.nvm/versions/node/v20.9.0/bin/cdk",
|
|
44
|
+
"console": "integratedTerminal",
|
|
45
|
+
"args": [
|
|
46
|
+
"synth",
|
|
47
|
+
"-a",
|
|
48
|
+
"python",
|
|
49
|
+
"${workspaceFolder}/src/cdk_factory/app.py",
|
|
50
|
+
"-c", "config=path/to/config.json"],
|
|
51
|
+
"env": {
|
|
52
|
+
|
|
53
|
+
"ENVRIONMENT": "dev",
|
|
54
|
+
"DEBUG_MODE": "True",
|
|
55
|
+
"PYTHONPATH": "${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/src/cdk_factory",
|
|
56
|
+
"RUN_INTEGRATION_TESTS": "True"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "CDK Synth: Static WebSite",
|
|
63
|
+
"type": "debugpy",
|
|
64
|
+
"request": "launch",
|
|
65
|
+
"program": "${workspaceFolder}/examples/website/static_website/devops/app.py",
|
|
66
|
+
"console": "integratedTerminal",
|
|
67
|
+
"env": {
|
|
68
|
+
"ENVRIONMENT": "dev",
|
|
69
|
+
"DEBUG_MODE": "True",
|
|
70
|
+
"PYTHONPATH": "${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/src/cdk_factory",
|
|
71
|
+
"RUN_INTEGRATION_TESTS": "True"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "Build & Deploy Artifacts",
|
|
76
|
+
"type": "debugpy",
|
|
77
|
+
"request": "launch",
|
|
78
|
+
"program": "${workspaceFolder}/devops/build.py",
|
|
79
|
+
"console": "integratedTerminal"
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
]
|
|
83
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"python.testing.unittestArgs": [
|
|
4
|
+
"-v",
|
|
5
|
+
"-s",
|
|
6
|
+
"./tests",
|
|
7
|
+
"-p",
|
|
8
|
+
"*test.py"
|
|
9
|
+
],
|
|
10
|
+
"python.testing.pytestEnabled": false,
|
|
11
|
+
"python.testing.unittestEnabled": true,
|
|
12
|
+
"python.analysis.typeCheckingMode": "off",
|
|
13
|
+
"python.analysis.extraPaths": [
|
|
14
|
+
"${workspaceFolder}/src",
|
|
15
|
+
"${workspaceFolder}/tests",
|
|
16
|
+
"${workspaceFolder}/examples",
|
|
17
|
+
"${workspaceFolder}/examples/website"
|
|
18
|
+
],
|
|
19
|
+
"[python]": {
|
|
20
|
+
|
|
21
|
+
"editor.formatOnSave": true,
|
|
22
|
+
"editor.codeActionsOnSave": {
|
|
23
|
+
"source.fixAll": "explicit",
|
|
24
|
+
"source.organizeImports": "explicit"
|
|
25
|
+
},
|
|
26
|
+
"editor.defaultFormatter": "charliermarsh.ruff",
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Geek Cafe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cdk_factory
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: CDK Factory. A QuickStarter and best practices setup for CDK projects
|
|
5
|
+
Author-email: Eric Wilson <eric.wilson@geekcafe.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: aws-cdk-lib
|
|
13
|
+
Requires-Dist: aws-lambda-powertools>=2.38.1
|
|
14
|
+
Requires-Dist: boto3-assist
|
|
15
|
+
Requires-Dist: constructs
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# cdk-factory
|
|
19
|
+
An AWS CDK wrapper for common deployments
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import List
|
|
7
|
+
|
|
8
|
+
import toml
|
|
9
|
+
from aws_lambda_powertools import Logger
|
|
10
|
+
|
|
11
|
+
logger = Logger()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
"""build the artifacts"""
|
|
16
|
+
project_root = Path(__file__).parent.parent
|
|
17
|
+
|
|
18
|
+
# extact the version
|
|
19
|
+
pyproject_toml = os.path.join(project_root, "pyproject.toml")
|
|
20
|
+
version_file = os.path.join(project_root, "src", "cdk_factory", "version.py")
|
|
21
|
+
extract_version_and_write_to_file(pyproject_toml, version_file)
|
|
22
|
+
# do the build
|
|
23
|
+
run_local_clean_up()
|
|
24
|
+
|
|
25
|
+
run_build()
|
|
26
|
+
run_publish()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def run_local_clean_up():
|
|
30
|
+
"""run a local clean up and remove older items in the dist directory"""
|
|
31
|
+
root = Path(__file__).parent.parent
|
|
32
|
+
dist_dir = os.path.join(root, "dist")
|
|
33
|
+
if os.path.exists(dist_dir):
|
|
34
|
+
# clear it out
|
|
35
|
+
shutil.rmtree(dist_dir)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def run_remote_clean_up():
|
|
39
|
+
"""
|
|
40
|
+
Clean out older versions
|
|
41
|
+
"""
|
|
42
|
+
logger.warning("warning/info: older versions are not being cleaned out.")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def extract_version_and_write_to_file(pyproject_toml: str, version_file: str):
|
|
46
|
+
"""
|
|
47
|
+
extract the version number from the pyproject.toml file and write it
|
|
48
|
+
to the version.py file
|
|
49
|
+
"""
|
|
50
|
+
if not os.path.exists(pyproject_toml):
|
|
51
|
+
raise FileNotFoundError(
|
|
52
|
+
f"The pyproject.toml file ({pyproject_toml}) not found. "
|
|
53
|
+
"Please check the path and try again."
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
with open(pyproject_toml, "r", encoding="utf-8") as file:
|
|
57
|
+
pyproject_data = toml.load(file)
|
|
58
|
+
version = pyproject_data["project"]["version"]
|
|
59
|
+
with open(version_file, "w", encoding="utf-8") as f:
|
|
60
|
+
f.write(f"__version__ = '{version}'\n")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def run_build():
|
|
64
|
+
"""Run python build commands"""
|
|
65
|
+
run_commands(["python", "-m", "build"])
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def run_publish():
|
|
69
|
+
"""publish to code artifact"""
|
|
70
|
+
|
|
71
|
+
# Set up the environment variables for the upload command
|
|
72
|
+
api_token = os.getenv("PYPI_API_TOKEN")
|
|
73
|
+
|
|
74
|
+
if not api_token:
|
|
75
|
+
raise ValueError("PYPI_API_TOKEN environment variable is not set.")
|
|
76
|
+
|
|
77
|
+
env = os.environ.copy()
|
|
78
|
+
env["TWINE_USERNAME"] = "__token__"
|
|
79
|
+
env["TWINE_PASSWORD"] = api_token
|
|
80
|
+
|
|
81
|
+
run_commands(
|
|
82
|
+
["python", "-m", "twine", "upload", "dist/*"],
|
|
83
|
+
env=env,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_url(payload: str):
|
|
88
|
+
"""get the url from the payload"""
|
|
89
|
+
value: dict = json.loads(payload)
|
|
90
|
+
url = value.get("repositoryEndpoint")
|
|
91
|
+
|
|
92
|
+
return url
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def run_commands(
|
|
96
|
+
commands: List[str], capture_output: bool = False, env=None
|
|
97
|
+
) -> str | None:
|
|
98
|
+
"""centralized area for running process commands"""
|
|
99
|
+
try:
|
|
100
|
+
# Run the publish command
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
commands,
|
|
103
|
+
check=True,
|
|
104
|
+
capture_output=capture_output,
|
|
105
|
+
env=env, # pass any environment vars
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if capture_output:
|
|
109
|
+
output = result.stdout.decode().strip()
|
|
110
|
+
print(output)
|
|
111
|
+
return output
|
|
112
|
+
|
|
113
|
+
except subprocess.CalledProcessError as e:
|
|
114
|
+
logger.exception(f"An error occurred: {e}")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
main()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# DevOps
|
|
2
|
+
|
|
3
|
+
## building
|
|
4
|
+
```sh
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## deploying
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
twine upload dist/*
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## uploading and testing with a "test"
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
|
|
19
|
+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
|
20
|
+
|
|
21
|
+
pip install --index-url https://test.pypi.org/simple/ boto3-assist
|
|
22
|
+
|
|
23
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# WebSite Pipeline
|
|
2
|
+
|
|
3
|
+
This sample deploys an AWS CodePipeline, which will do the following
|
|
4
|
+
|
|
5
|
+
1. Builds the AWS CodePipeline
|
|
6
|
+
2. Connects to a repo like GitHub, AWS CodeCommit, etc
|
|
7
|
+
3. The first time this is runs CodePipeline also runs
|
|
8
|
+
4. Subsequent check-ins will run the Pipeline
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
project_root = Path(__file__).parents[4].absolute()
|
|
6
|
+
print(f"project root: {project_root}")
|
|
7
|
+
## needed for discovery based top level execution
|
|
8
|
+
sys.path.insert(0, os.path.join(project_root))
|
|
9
|
+
sys.path.insert(0, os.path.join(project_root, "src"))
|
|
10
|
+
sys.path.insert(0, os.path.join(project_root, "src", "cdk_factory"))
|
|
11
|
+
sys.path.insert(0, os.path.join(project_root, "examples"))
|
|
12
|
+
sys.path.insert(0, os.path.join(project_root, "examples", "website"))
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Geek Cafe, LLC
|
|
3
|
+
Maintainers: Eric Wilson
|
|
4
|
+
MIT License. See Project Root for the license information.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
# import __paths__
|
|
11
|
+
from cdk_factory.app import CdkAppFactory
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MyStaticWebSiteApp:
|
|
15
|
+
"""My Static WebSite Example"""
|
|
16
|
+
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.name = "MyApp"
|
|
19
|
+
|
|
20
|
+
def synth(self):
|
|
21
|
+
"""Synth my static web site"""
|
|
22
|
+
print("synth", self.name)
|
|
23
|
+
path = str(Path(__file__).parent)
|
|
24
|
+
config_path = os.path.join(path, "config.json")
|
|
25
|
+
if not os.path.exists(config_path):
|
|
26
|
+
raise FileNotFoundError(config_path)
|
|
27
|
+
|
|
28
|
+
# the CdkAppFactory will use some "canned" or pre-made stacks
|
|
29
|
+
factory: CdkAppFactory = CdkAppFactory(config=config_path)
|
|
30
|
+
|
|
31
|
+
# this provides a way to inject stacks from this module
|
|
32
|
+
# stacks: Stacks = Stacks(app=factory.app)
|
|
33
|
+
# stacks.synth()
|
|
34
|
+
|
|
35
|
+
# something like this to add to the pipeline(s)
|
|
36
|
+
# factory.pipelines["dev"].stages.add("dev", stack=stacks.stacks)
|
|
37
|
+
cdk_app_file = "./examples/website/static_website/devops/app.py"
|
|
38
|
+
print(
|
|
39
|
+
"👉 Synthing - this runs local and then later in AWS if a self mutate happens"
|
|
40
|
+
)
|
|
41
|
+
print(
|
|
42
|
+
(
|
|
43
|
+
"🚨 Warning - be careful when adding paths. You don't want to bake in a local path "
|
|
44
|
+
"or a runtime build path that gets carried over into the next build."
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
print("synth:synthing path:", cdk_app_file)
|
|
49
|
+
print("synth:file path", __file__)
|
|
50
|
+
print("synth: PWD", os.getenv("PWD"))
|
|
51
|
+
|
|
52
|
+
return factory.synth(paths=[path], cdk_app_file=cdk_app_file)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main():
|
|
56
|
+
"""Run the app"""
|
|
57
|
+
app = MyStaticWebSiteApp()
|
|
58
|
+
app.synth()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
main()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": "python3 app.py",
|
|
3
|
+
"watch": {
|
|
4
|
+
"include": [
|
|
5
|
+
"**"
|
|
6
|
+
],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"README.md",
|
|
9
|
+
"cdk*.json",
|
|
10
|
+
"requirements*.txt",
|
|
11
|
+
"source.bat",
|
|
12
|
+
"**/__init__.py",
|
|
13
|
+
"**/__pycache__",
|
|
14
|
+
"tests"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"context": {
|
|
18
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
19
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
20
|
+
"@aws-cdk/core:target-partitions": [
|
|
21
|
+
"aws",
|
|
22
|
+
"aws-cn"
|
|
23
|
+
],
|
|
24
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
25
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
26
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
27
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
28
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
29
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
30
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
31
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
32
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
33
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
34
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
35
|
+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
|
|
36
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
37
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
38
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
39
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
40
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
41
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
42
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
43
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
44
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
45
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
46
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
47
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
48
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
49
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
50
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
51
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
52
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
53
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
54
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
55
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
56
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
57
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
58
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
59
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
60
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
61
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
echo building for branch: ${GIT_BRANCH_NAME}
|
|
2
|
+
python --version
|
|
3
|
+
|
|
4
|
+
if [ -n "$PYTHON_312_VERSION" ]; then echo "Switching to Python version ${PYTHON_312_VERSION} - using environment var for version"; pyenv global "${PYTHON_312_VERSION}"; fi
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
python --version
|
|
8
|
+
echo printing environment vars
|
|
9
|
+
env
|
|
10
|
+
echo Extracting stack name from CODEBUILD_INITIATOR
|
|
11
|
+
echo $CODEBUILD_INITIATOR
|
|
12
|
+
# Extract the second part of CODEBUILD_INITIATOR (stack name)
|
|
13
|
+
STACK_NAME=$(echo $CODEBUILD_INITIATOR | cut -d'/' -f2)
|
|
14
|
+
echo Stack name is $STACK_NAME
|
|
15
|
+
echo $(pwd)
|
|
16
|
+
export WORKING_DIRECTORY=$(pwd)
|
|
17
|
+
echo $WORKING_DIRECTORY
|
|
18
|
+
# install the main cdk-factory (we'll remove this later - once we publish the package)
|
|
19
|
+
pip install -r ./src/requirements.txt
|
|
20
|
+
pip install -e .
|
|
21
|
+
# install our example (this will be the main project)
|
|
22
|
+
pip install -e ./examples/website/static_website
|
|
23
|
+
|
|
24
|
+
# change to our samples project
|
|
25
|
+
cd ./examples/website/static_website/devops
|
|
26
|
+
echo $(pwd)
|
|
27
|
+
echo Installing requirements
|
|
28
|
+
# install requirement
|
|
29
|
+
pip install -r requirements.txt
|
|
30
|
+
npx cdk synth {verbose} $STACK_NAME
|
|
31
|
+
|
|
32
|
+
echo CDK Synth Complete
|
|
33
|
+
echo $(pwd)
|
|
34
|
+
echo Listing Files in the sub project folder
|
|
35
|
+
ls -la
|
|
36
|
+
echo switch back to main path
|
|
37
|
+
cd $WORKING_DIRECTORY
|
|
38
|
+
echo $(pwd)
|
|
39
|
+
ls -la
|
|
40
|
+
echo CDK Synth Complete
|