dbt-platform-helper 12.0.2__tar.gz → 12.2.0__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.
Potentially problematic release.
This version of dbt-platform-helper might be problematic. Click here for more details.
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/PKG-INFO +2 -1
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/COMMANDS.md +7 -8
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/application.py +1 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/commands/codebase.py +146 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/commands/conduit.py +78 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/secrets.py +1 -1
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/constants.py +12 -1
- dbt_platform_helper-12.2.0/dbt_platform_helper/domain/codebase.py +222 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/domain/conduit.py +172 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/domain/database_copy.py +1 -1
- dbt_platform_helper-12.2.0/dbt_platform_helper/exceptions.py +81 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/providers/cloudformation.py +105 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/providers/copilot.py +144 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/providers/ecs.py +78 -0
- dbt_platform_helper-12.2.0/dbt_platform_helper/providers/secrets.py +85 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addons/svc/prometheus-policy.yml +2 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/environments/manifest.yml +0 -1
- dbt_platform_helper-12.2.0/dbt_platform_helper/utils/__init__.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/application.py +1 -4
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/aws.py +132 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/files.py +70 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/git.py +13 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/validation.py +121 -3
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/pyproject.toml +1 -1
- dbt_platform_helper-12.0.2/dbt_platform_helper/commands/codebase.py +0 -311
- dbt_platform_helper-12.0.2/dbt_platform_helper/commands/conduit.py +0 -453
- dbt_platform_helper-12.0.2/dbt_platform_helper/exceptions.py +0 -20
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/README.md +0 -11
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/bin/override.ts +0 -9
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/log_resource_policy.json +0 -68
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/package-lock.json +0 -4307
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/package.json +0 -27
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/stack.ts +0 -51
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env/overrides/tsconfig.json +0 -32
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/pipelines/codebase/overrides/.gitignore +0 -12
- dbt_platform_helper-12.0.2/dbt_platform_helper/templates/pipelines/codebase/overrides/cdk.json +0 -20
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/LICENSE +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/README.md +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/__init__.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/addon-plans.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/addons-template-map.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/__init__.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/config.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/copilot.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/database.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/environment.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/generate.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/notify.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/pipeline.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/version.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/default-extensions.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/domain/__init__.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/domain/maintenance_page.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/jinja2_tags.py +0 -0
- {dbt_platform_helper-12.0.2/dbt_platform_helper/utils → dbt_platform_helper-12.2.0/dbt_platform_helper/providers}/__init__.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/providers/load_balancers.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/config.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/image_build_run.sh +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/phases/build.sh +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/phases/install.sh +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/phases/post_build.sh +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/.copilot/phases/pre_build.sh +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/COMMANDS.md.jinja +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addon-instructions.txt +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addons/README.md +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addons/svc/s3-policy.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/addons/svc/subscription-filter.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/ci-codebuild-role-policy.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/create-codebuild-role.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/custom-codebuild-role-policy.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/env/manifest.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/env/terraform-overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/environment-pipelines/main.tf +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/environments/main.tf +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/manifest.yml +0 -0
- {dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env → dbt_platform_helper-12.2.0/dbt_platform_helper/templates/pipelines/codebase}/overrides/.gitignore +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/bin/override.ts +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.deploy.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.image.yml +0 -0
- {dbt_platform_helper-12.0.2/dbt_platform_helper/templates/env → dbt_platform_helper-12.2.0/dbt_platform_helper/templates/pipelines/codebase}/overrides/cdk.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/package-lock.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/package.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/stack.ts +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/tsconfig.json +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/types.ts +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/environments/buildspec.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/pipelines/environments/overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/maintenance_pages/default.html +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/maintenance_pages/dmas-migration.html +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/maintenance_pages/migration.html +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/manifest-backend.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/manifest-public.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/templates/svc/overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/arn_parser.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/click.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/cloudfoundry.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/manifests.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/messages.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/platform_config.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/template.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/utils/versioning.py +0 -0
- {dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/platform_helper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dbt-platform-helper
|
|
3
|
-
Version: 12.0
|
|
3
|
+
Version: 12.2.0
|
|
4
4
|
Summary: Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Department for Business and Trade Platform Team
|
|
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
16
|
Requires-Dist: Jinja2 (==3.1.4)
|
|
16
17
|
Requires-Dist: PyYAML (==6.0.1)
|
|
17
18
|
Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
|
|
@@ -222,7 +222,7 @@ platform-helper codebase build --app <application> --codebase <codebase>
|
|
|
222
222
|
- `--app <text>`
|
|
223
223
|
- AWS application name
|
|
224
224
|
- `--codebase <text>`
|
|
225
|
-
- The codebase name as specified in the
|
|
225
|
+
- The codebase name as specified in the platform-config.yml file
|
|
226
226
|
- `--commit <text>`
|
|
227
227
|
- GitHub commit hash
|
|
228
228
|
- `--help <boolean>` _Defaults to False._
|
|
@@ -232,8 +232,6 @@ platform-helper codebase build --app <application> --codebase <codebase>
|
|
|
232
232
|
|
|
233
233
|
[↩ Parent](#platform-helper-codebase)
|
|
234
234
|
|
|
235
|
-
Trigger a CodePipeline pipeline based deployment.
|
|
236
|
-
|
|
237
235
|
## Usage
|
|
238
236
|
|
|
239
237
|
```
|
|
@@ -248,7 +246,7 @@ platform-helper codebase deploy --app <application> --env <environment> --codeba
|
|
|
248
246
|
- `--env <text>`
|
|
249
247
|
- AWS Copilot environment
|
|
250
248
|
- `--codebase <text>`
|
|
251
|
-
- The codebase name as specified in the
|
|
249
|
+
- The codebase name as specified in the platform-config.yml file
|
|
252
250
|
- `--commit <text>`
|
|
253
251
|
- GitHub commit hash
|
|
254
252
|
- `--help <boolean>` _Defaults to False._
|
|
@@ -258,7 +256,8 @@ platform-helper codebase deploy --app <application> --env <environment> --codeba
|
|
|
258
256
|
|
|
259
257
|
[↩ Parent](#platform-helper)
|
|
260
258
|
|
|
261
|
-
|
|
259
|
+
Opens a shell for a given addon_name create a conduit connection to
|
|
260
|
+
interact with postgres, opensearch or redis.
|
|
262
261
|
|
|
263
262
|
## Usage
|
|
264
263
|
|
|
@@ -274,11 +273,11 @@ platform-helper conduit <addon_name>
|
|
|
274
273
|
## Options
|
|
275
274
|
|
|
276
275
|
- `--app <text>`
|
|
277
|
-
-
|
|
276
|
+
- Application name
|
|
278
277
|
- `--env <text>`
|
|
279
|
-
-
|
|
278
|
+
- Environment name
|
|
280
279
|
- `--access <choice>` _Defaults to read._
|
|
281
|
-
- Allow write or admin access to database addons
|
|
280
|
+
- Allow read, write or admin access to the database addons.
|
|
282
281
|
- `--help <boolean>` _Defaults to False._
|
|
283
282
|
- Show this message and exit.
|
|
284
283
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
|
|
6
|
+
from dbt_platform_helper.domain.codebase import Codebase
|
|
7
|
+
from dbt_platform_helper.exceptions import ApplicationDeploymentNotTriggered
|
|
8
|
+
from dbt_platform_helper.exceptions import ApplicationEnvironmentNotFoundError
|
|
9
|
+
from dbt_platform_helper.exceptions import ApplicationNotFoundError
|
|
10
|
+
from dbt_platform_helper.exceptions import CopilotCodebaseNotFoundError
|
|
11
|
+
from dbt_platform_helper.exceptions import ImageNotFoundError
|
|
12
|
+
from dbt_platform_helper.exceptions import NoCopilotCodebasesFoundError
|
|
13
|
+
from dbt_platform_helper.exceptions import NotInCodeBaseRepositoryError
|
|
14
|
+
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
15
|
+
from dbt_platform_helper.utils.git import CommitNotFoundError
|
|
16
|
+
from dbt_platform_helper.utils.versioning import (
|
|
17
|
+
check_platform_helper_version_needs_update,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
22
|
+
def codebase():
|
|
23
|
+
"""Codebase commands."""
|
|
24
|
+
check_platform_helper_version_needs_update()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@codebase.command()
|
|
28
|
+
def prepare():
|
|
29
|
+
"""Sets up an application codebase for use within a DBT platform project."""
|
|
30
|
+
try:
|
|
31
|
+
Codebase().prepare()
|
|
32
|
+
except NotInCodeBaseRepositoryError:
|
|
33
|
+
# TODO: Set exception message in the exceptions and just output the message in the command code
|
|
34
|
+
click.secho(
|
|
35
|
+
"You are in the deploy repository; make sure you are in the application codebase repository.",
|
|
36
|
+
fg="red",
|
|
37
|
+
)
|
|
38
|
+
raise click.Abort
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@codebase.command()
|
|
42
|
+
@click.option("--app", help="AWS application name", required=True)
|
|
43
|
+
@click.option(
|
|
44
|
+
"--with-images",
|
|
45
|
+
help="List up to the last 10 images tagged for this codebase",
|
|
46
|
+
default=False,
|
|
47
|
+
is_flag=True,
|
|
48
|
+
)
|
|
49
|
+
def list(app, with_images):
|
|
50
|
+
"""List available codebases for the application."""
|
|
51
|
+
try:
|
|
52
|
+
Codebase().list(app, with_images)
|
|
53
|
+
except NoCopilotCodebasesFoundError:
|
|
54
|
+
click.secho(
|
|
55
|
+
f"""No codebases found for application "{app}""",
|
|
56
|
+
fg="red",
|
|
57
|
+
)
|
|
58
|
+
raise click.Abort
|
|
59
|
+
except ApplicationNotFoundError:
|
|
60
|
+
click.secho(
|
|
61
|
+
f"""The account "{os.environ.get("AWS_PROFILE")}" does not contain the application "{app}"; ensure you have set the environment variable "AWS_PROFILE" correctly.""",
|
|
62
|
+
fg="red",
|
|
63
|
+
)
|
|
64
|
+
raise click.Abort
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@codebase.command()
|
|
68
|
+
@click.option("--app", help="AWS application name", required=True)
|
|
69
|
+
@click.option(
|
|
70
|
+
"--codebase",
|
|
71
|
+
help="The codebase name as specified in the platform-config.yml file",
|
|
72
|
+
required=True,
|
|
73
|
+
)
|
|
74
|
+
@click.option("--commit", help="GitHub commit hash", required=True)
|
|
75
|
+
def build(app, codebase, commit):
|
|
76
|
+
"""Trigger a CodePipeline pipeline based build."""
|
|
77
|
+
try:
|
|
78
|
+
Codebase().build(app, codebase, commit)
|
|
79
|
+
except ApplicationNotFoundError:
|
|
80
|
+
click.secho(
|
|
81
|
+
f"""The account "{os.environ.get("AWS_PROFILE")}" does not contain the application "{app}"; ensure you have set the environment variable "AWS_PROFILE" correctly.""",
|
|
82
|
+
fg="red",
|
|
83
|
+
)
|
|
84
|
+
raise click.Abort
|
|
85
|
+
except CommitNotFoundError:
|
|
86
|
+
click.secho(
|
|
87
|
+
f'The commit hash "{commit}" either does not exist or you need to run `git fetch`.',
|
|
88
|
+
fg="red",
|
|
89
|
+
)
|
|
90
|
+
raise click.Abort
|
|
91
|
+
except ApplicationDeploymentNotTriggered:
|
|
92
|
+
click.secho(
|
|
93
|
+
f"Your build for {codebase} was not triggered.",
|
|
94
|
+
fg="red",
|
|
95
|
+
)
|
|
96
|
+
raise click.Abort
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@codebase.command()
|
|
100
|
+
@click.option("--app", help="AWS application name", required=True)
|
|
101
|
+
@click.option("--env", help="AWS Copilot environment", required=True)
|
|
102
|
+
@click.option(
|
|
103
|
+
"--codebase",
|
|
104
|
+
help="The codebase name as specified in the platform-config.yml file",
|
|
105
|
+
required=True,
|
|
106
|
+
)
|
|
107
|
+
@click.option("--commit", help="GitHub commit hash", required=True)
|
|
108
|
+
def deploy(app, env, codebase, commit):
|
|
109
|
+
try:
|
|
110
|
+
Codebase().deploy(app, env, codebase, commit)
|
|
111
|
+
except ApplicationNotFoundError:
|
|
112
|
+
# TODO: Set exception message in the exceptions and just output the message in the command code
|
|
113
|
+
click.secho(
|
|
114
|
+
f"""The account "{os.environ.get("AWS_PROFILE")}" does not contain the application "{app}"; ensure you have set the environment variable "AWS_PROFILE" correctly.""",
|
|
115
|
+
fg="red",
|
|
116
|
+
)
|
|
117
|
+
raise click.Abort
|
|
118
|
+
except ApplicationEnvironmentNotFoundError:
|
|
119
|
+
click.secho(
|
|
120
|
+
f"""The environment "{env}" either does not exist or has not been deployed.""",
|
|
121
|
+
fg="red",
|
|
122
|
+
)
|
|
123
|
+
raise click.Abort
|
|
124
|
+
except (
|
|
125
|
+
CopilotCodebaseNotFoundError,
|
|
126
|
+
# TODO: Catch this error earlier and throw a more meaningful error, maybe it's CopilotCodebaseNotFoundError?
|
|
127
|
+
json.JSONDecodeError,
|
|
128
|
+
):
|
|
129
|
+
click.secho(
|
|
130
|
+
f"""The codebase "{codebase}" either does not exist or has not been deployed.""",
|
|
131
|
+
fg="red",
|
|
132
|
+
)
|
|
133
|
+
raise click.Abort
|
|
134
|
+
except ImageNotFoundError:
|
|
135
|
+
click.secho(
|
|
136
|
+
f'The commit hash "{commit}" has not been built into an image, try the '
|
|
137
|
+
"`platform-helper codebase build` command first.",
|
|
138
|
+
fg="red",
|
|
139
|
+
)
|
|
140
|
+
raise click.Abort
|
|
141
|
+
except ApplicationDeploymentNotTriggered:
|
|
142
|
+
click.secho(
|
|
143
|
+
f"Your deployment for {codebase} was not triggered.",
|
|
144
|
+
fg="red",
|
|
145
|
+
)
|
|
146
|
+
raise click.Abort
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from dbt_platform_helper.constants import CONDUIT_ADDON_TYPES
|
|
4
|
+
from dbt_platform_helper.domain.conduit import Conduit
|
|
5
|
+
from dbt_platform_helper.exceptions import AddonNotFoundError
|
|
6
|
+
from dbt_platform_helper.exceptions import AddonTypeMissingFromConfigError
|
|
7
|
+
from dbt_platform_helper.exceptions import CreateTaskTimeoutError
|
|
8
|
+
from dbt_platform_helper.exceptions import InvalidAddonTypeError
|
|
9
|
+
from dbt_platform_helper.exceptions import NoClusterError
|
|
10
|
+
from dbt_platform_helper.exceptions import ParameterNotFoundError
|
|
11
|
+
from dbt_platform_helper.providers.secrets import SecretNotFoundError
|
|
12
|
+
from dbt_platform_helper.utils.application import load_application
|
|
13
|
+
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
14
|
+
from dbt_platform_helper.utils.versioning import (
|
|
15
|
+
check_platform_helper_version_needs_update,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
CONDUIT_ACCESS_OPTIONS = ["read", "write", "admin"]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.command(cls=ClickDocOptCommand)
|
|
22
|
+
@click.argument("addon_name", type=str, required=True)
|
|
23
|
+
@click.option("--app", help="Application name", required=True)
|
|
24
|
+
@click.option("--env", help="Environment name", required=True)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--access",
|
|
27
|
+
default="read",
|
|
28
|
+
type=click.Choice(CONDUIT_ACCESS_OPTIONS),
|
|
29
|
+
help="Allow read, write or admin access to the database addons.",
|
|
30
|
+
)
|
|
31
|
+
def conduit(addon_name: str, app: str, env: str, access: str):
|
|
32
|
+
"""Opens a shell for a given addon_name create a conduit connection to
|
|
33
|
+
interact with postgres, opensearch or redis."""
|
|
34
|
+
check_platform_helper_version_needs_update()
|
|
35
|
+
application = load_application(app)
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
Conduit(application).start(env, addon_name, access)
|
|
39
|
+
except NoClusterError:
|
|
40
|
+
# TODO: Set exception message in the exceptions and just output the message in the command code, should be able to catch all errors in one block
|
|
41
|
+
click.secho(f"""No ECS cluster found for "{app}" in "{env}" environment.""", fg="red")
|
|
42
|
+
exit(1)
|
|
43
|
+
except SecretNotFoundError as err:
|
|
44
|
+
click.secho(
|
|
45
|
+
f"""No secret called "{err}" for "{app}" in "{env}" environment.""",
|
|
46
|
+
fg="red",
|
|
47
|
+
)
|
|
48
|
+
exit(1)
|
|
49
|
+
except CreateTaskTimeoutError:
|
|
50
|
+
click.secho(
|
|
51
|
+
f"""Client ({addon_name}) ECS task has failed to start for "{app}" in "{env}" environment.""",
|
|
52
|
+
fg="red",
|
|
53
|
+
)
|
|
54
|
+
exit(1)
|
|
55
|
+
except ParameterNotFoundError:
|
|
56
|
+
click.secho(
|
|
57
|
+
f"""No parameter called "/copilot/applications/{app}/environments/{env}/addons". Try deploying the "{app}" "{env}" environment.""",
|
|
58
|
+
fg="red",
|
|
59
|
+
)
|
|
60
|
+
exit(1)
|
|
61
|
+
except AddonNotFoundError:
|
|
62
|
+
click.secho(
|
|
63
|
+
f"""Addon "{addon_name}" does not exist.""",
|
|
64
|
+
fg="red",
|
|
65
|
+
)
|
|
66
|
+
exit(1)
|
|
67
|
+
except InvalidAddonTypeError as err:
|
|
68
|
+
click.secho(
|
|
69
|
+
f"""Addon type "{err.addon_type}" is not supported, we support: {", ".join(CONDUIT_ADDON_TYPES)}.""",
|
|
70
|
+
fg="red",
|
|
71
|
+
)
|
|
72
|
+
exit(1)
|
|
73
|
+
except AddonTypeMissingFromConfigError:
|
|
74
|
+
click.secho(
|
|
75
|
+
f"""The configuration for the addon {addon_name}, is missconfigured and missing the addon type.""",
|
|
76
|
+
fg="red",
|
|
77
|
+
)
|
|
78
|
+
exit(1)
|
{dbt_platform_helper-12.0.2 → dbt_platform_helper-12.2.0}/dbt_platform_helper/commands/secrets.py
RENAMED
|
@@ -102,7 +102,7 @@ def list(app, env):
|
|
|
102
102
|
params = dict(Path=path, Recursive=False, WithDecryption=True, MaxResults=10)
|
|
103
103
|
secrets = []
|
|
104
104
|
|
|
105
|
-
# TODO: refactor shared code with get_ssm_secret_names
|
|
105
|
+
# TODO: refactor shared code with get_ssm_secret_names - Check if this is still valid
|
|
106
106
|
while True:
|
|
107
107
|
response = client.get_parameters_by_path(**params)
|
|
108
108
|
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
PLATFORM_CONFIG_FILE = "platform-config.yml"
|
|
2
2
|
PLATFORM_HELPER_VERSION_FILE = ".platform-helper-version"
|
|
3
|
+
DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION = "5"
|
|
4
|
+
PLATFORM_HELPER_CACHE_FILE = ".platform-helper-config-cache.yml"
|
|
5
|
+
|
|
6
|
+
# Keys
|
|
3
7
|
CODEBASE_PIPELINES_KEY = "codebase_pipelines"
|
|
4
8
|
ENVIRONMENTS_KEY = "environments"
|
|
5
|
-
|
|
9
|
+
|
|
10
|
+
# Conduit
|
|
11
|
+
CONDUIT_ADDON_TYPES = [
|
|
12
|
+
"opensearch",
|
|
13
|
+
"postgres",
|
|
14
|
+
"redis",
|
|
15
|
+
]
|
|
16
|
+
CONDUIT_DOCKER_IMAGE_LOCATION = "public.ecr.aws/uktrade/tunnel"
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import stat
|
|
3
|
+
import subprocess
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
import requests
|
|
9
|
+
import yaml
|
|
10
|
+
from boto3 import Session
|
|
11
|
+
|
|
12
|
+
from dbt_platform_helper.exceptions import ApplicationDeploymentNotTriggered
|
|
13
|
+
from dbt_platform_helper.exceptions import ApplicationEnvironmentNotFoundError
|
|
14
|
+
from dbt_platform_helper.exceptions import NoCopilotCodebasesFoundError
|
|
15
|
+
from dbt_platform_helper.exceptions import NotInCodeBaseRepositoryError
|
|
16
|
+
from dbt_platform_helper.utils.application import Application
|
|
17
|
+
from dbt_platform_helper.utils.application import load_application
|
|
18
|
+
from dbt_platform_helper.utils.aws import check_codebase_exists
|
|
19
|
+
from dbt_platform_helper.utils.aws import check_image_exists
|
|
20
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
21
|
+
from dbt_platform_helper.utils.aws import get_build_url_from_arn
|
|
22
|
+
from dbt_platform_helper.utils.aws import list_latest_images
|
|
23
|
+
from dbt_platform_helper.utils.aws import start_build_extraction
|
|
24
|
+
from dbt_platform_helper.utils.files import mkfile
|
|
25
|
+
from dbt_platform_helper.utils.git import check_if_commit_exists
|
|
26
|
+
from dbt_platform_helper.utils.template import setup_templates
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Codebase:
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
input_fn: Callable[[str], str] = click.prompt,
|
|
33
|
+
echo_fn: Callable[[str], str] = click.secho,
|
|
34
|
+
confirm_fn: Callable[[str], bool] = click.confirm,
|
|
35
|
+
load_application_fn: Callable[[str], Application] = load_application,
|
|
36
|
+
get_aws_session_or_abort_fn: Callable[[str], Session] = get_aws_session_or_abort,
|
|
37
|
+
check_codebase_exists_fn: Callable[[str], str] = check_codebase_exists,
|
|
38
|
+
check_image_exists_fn: Callable[[str], str] = check_image_exists,
|
|
39
|
+
get_build_url_from_arn_fn: Callable[[str], str] = get_build_url_from_arn,
|
|
40
|
+
list_latest_images_fn: Callable[[str], str] = list_latest_images,
|
|
41
|
+
start_build_extraction_fn: Callable[[str], str] = start_build_extraction,
|
|
42
|
+
check_if_commit_exists_fn: Callable[[str], str] = check_if_commit_exists,
|
|
43
|
+
subprocess: Callable[[str], str] = subprocess.run,
|
|
44
|
+
):
|
|
45
|
+
self.input_fn = input_fn
|
|
46
|
+
self.echo_fn = echo_fn
|
|
47
|
+
self.confirm_fn = confirm_fn
|
|
48
|
+
self.load_application_fn = load_application_fn
|
|
49
|
+
self.get_aws_session_or_abort_fn = get_aws_session_or_abort_fn
|
|
50
|
+
self.check_codebase_exists_fn = check_codebase_exists_fn
|
|
51
|
+
self.check_image_exists_fn = check_image_exists_fn
|
|
52
|
+
self.get_build_url_from_arn_fn = get_build_url_from_arn_fn
|
|
53
|
+
self.list_latest_images_fn = list_latest_images_fn
|
|
54
|
+
self.start_build_extraction_fn = start_build_extraction_fn
|
|
55
|
+
self.check_if_commit_exists_fn = check_if_commit_exists_fn
|
|
56
|
+
self.subprocess = subprocess
|
|
57
|
+
|
|
58
|
+
def prepare(self):
|
|
59
|
+
"""Sets up an application codebase for use within a DBT platform
|
|
60
|
+
project."""
|
|
61
|
+
templates = setup_templates()
|
|
62
|
+
|
|
63
|
+
repository = (
|
|
64
|
+
self.subprocess(["git", "remote", "get-url", "origin"], capture_output=True, text=True)
|
|
65
|
+
.stdout.split("/")[-1]
|
|
66
|
+
.strip()
|
|
67
|
+
.removesuffix(".git")
|
|
68
|
+
)
|
|
69
|
+
if repository.endswith("-deploy") or Path("./copilot").exists():
|
|
70
|
+
raise NotInCodeBaseRepositoryError
|
|
71
|
+
|
|
72
|
+
builder_configuration_url = "https://raw.githubusercontent.com/uktrade/ci-image-builder/main/image_builder/configuration/builder_configuration.yml"
|
|
73
|
+
builder_configuration_response = requests.get(builder_configuration_url)
|
|
74
|
+
builder_configuration_content = yaml.safe_load(
|
|
75
|
+
builder_configuration_response.content.decode("utf-8")
|
|
76
|
+
)
|
|
77
|
+
builder_versions = next(
|
|
78
|
+
(
|
|
79
|
+
item
|
|
80
|
+
for item in builder_configuration_content["builders"]
|
|
81
|
+
if item["name"] == "paketobuildpacks/builder-jammy-base"
|
|
82
|
+
),
|
|
83
|
+
None,
|
|
84
|
+
)
|
|
85
|
+
builder_version = max(x["version"] for x in builder_versions["versions"])
|
|
86
|
+
builder_version = min(builder_version, "0.4.240")
|
|
87
|
+
|
|
88
|
+
Path("./.copilot/phases").mkdir(parents=True, exist_ok=True)
|
|
89
|
+
image_build_run_contents = templates.get_template(f".copilot/image_build_run.sh").render()
|
|
90
|
+
|
|
91
|
+
config_contents = templates.get_template(f".copilot/config.yml").render(
|
|
92
|
+
repository=repository, builder_version=builder_version
|
|
93
|
+
)
|
|
94
|
+
self.echo_fn(
|
|
95
|
+
mkfile(
|
|
96
|
+
Path("."), ".copilot/image_build_run.sh", image_build_run_contents, overwrite=True
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
image_build_run_file = Path(".copilot/image_build_run.sh")
|
|
101
|
+
image_build_run_file.chmod(image_build_run_file.stat().st_mode | stat.S_IEXEC)
|
|
102
|
+
|
|
103
|
+
self.echo_fn(mkfile(Path("."), ".copilot/config.yml", config_contents, overwrite=True))
|
|
104
|
+
|
|
105
|
+
for phase in ["build", "install", "post_build", "pre_build"]:
|
|
106
|
+
phase_contents = templates.get_template(f".copilot/phases/{phase}.sh").render()
|
|
107
|
+
|
|
108
|
+
self.echo_fn(
|
|
109
|
+
mkfile(Path("./.copilot"), f"phases/{phase}.sh", phase_contents, overwrite=True)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def build(self, app: str, codebase: str, commit: str):
|
|
113
|
+
"""Trigger a CodePipeline pipeline based build."""
|
|
114
|
+
session = self.get_aws_session_or_abort_fn()
|
|
115
|
+
self.load_application_fn(app, default_session=session)
|
|
116
|
+
|
|
117
|
+
self.check_if_commit_exists_fn(commit)
|
|
118
|
+
|
|
119
|
+
codebuild_client = session.client("codebuild")
|
|
120
|
+
build_url = self.__start_build_with_confirmation(
|
|
121
|
+
self.confirm_fn,
|
|
122
|
+
codebuild_client,
|
|
123
|
+
self.get_build_url_from_arn_fn,
|
|
124
|
+
f'You are about to build "{app}" for "{codebase}" with commit "{commit}". Do you want to continue?',
|
|
125
|
+
{
|
|
126
|
+
"projectName": f"codebuild-{app}-{codebase}",
|
|
127
|
+
"artifactsOverride": {"type": "NO_ARTIFACTS"},
|
|
128
|
+
"sourceVersion": commit,
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if build_url:
|
|
133
|
+
return self.echo_fn(
|
|
134
|
+
f"Your build has been triggered. Check your build progress in the AWS Console: {build_url}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
raise ApplicationDeploymentNotTriggered()
|
|
138
|
+
|
|
139
|
+
def deploy(self, app, env, codebase, commit):
|
|
140
|
+
"""Trigger a CodePipeline pipeline based deployment."""
|
|
141
|
+
session = self.get_aws_session_or_abort_fn()
|
|
142
|
+
|
|
143
|
+
application = self.load_application_fn(app, default_session=session)
|
|
144
|
+
if not application.environments.get(env):
|
|
145
|
+
raise ApplicationEnvironmentNotFoundError()
|
|
146
|
+
|
|
147
|
+
json.loads(self.check_codebase_exists_fn(session, application, codebase))
|
|
148
|
+
|
|
149
|
+
self.check_image_exists_fn(session, application, codebase, commit)
|
|
150
|
+
|
|
151
|
+
codebuild_client = session.client("codebuild")
|
|
152
|
+
build_url = self.__start_build_with_confirmation(
|
|
153
|
+
self.confirm_fn,
|
|
154
|
+
codebuild_client,
|
|
155
|
+
self.get_build_url_from_arn_fn,
|
|
156
|
+
f'You are about to deploy "{app}" for "{codebase}" with commit "{commit}" to the "{env}" environment. Do you want to continue?',
|
|
157
|
+
{
|
|
158
|
+
"projectName": f"pipeline-{application.name}-{codebase}-BuildProject",
|
|
159
|
+
"artifactsOverride": {"type": "NO_ARTIFACTS"},
|
|
160
|
+
"sourceTypeOverride": "NO_SOURCE",
|
|
161
|
+
"environmentVariablesOverride": [
|
|
162
|
+
{"name": "COPILOT_ENVIRONMENT", "value": env},
|
|
163
|
+
{"name": "IMAGE_TAG", "value": f"commit-{commit}"},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
if build_url:
|
|
169
|
+
return self.echo_fn(
|
|
170
|
+
"Your deployment has been triggered. Check your build progress in the AWS Console: "
|
|
171
|
+
f"{build_url}",
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
raise ApplicationDeploymentNotTriggered()
|
|
175
|
+
|
|
176
|
+
def list(self, app: str, with_images: bool):
|
|
177
|
+
"""List available codebases for the application."""
|
|
178
|
+
session = self.get_aws_session_or_abort_fn()
|
|
179
|
+
application = self.load_application_fn(app, session)
|
|
180
|
+
ssm_client = session.client("ssm")
|
|
181
|
+
ecr_client = session.client("ecr")
|
|
182
|
+
codebases = self.__get_codebases(application, ssm_client)
|
|
183
|
+
|
|
184
|
+
self.echo_fn("The following codebases are available:")
|
|
185
|
+
|
|
186
|
+
for codebase in codebases:
|
|
187
|
+
self.echo_fn(f"- {codebase['name']} (https://github.com/{codebase['repository']})")
|
|
188
|
+
if with_images:
|
|
189
|
+
self.list_latest_images_fn(
|
|
190
|
+
ecr_client,
|
|
191
|
+
f"{application.name}/{codebase['name']}",
|
|
192
|
+
codebase["repository"],
|
|
193
|
+
self.echo_fn,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
self.echo_fn("")
|
|
197
|
+
|
|
198
|
+
def __get_codebases(self, application, ssm_client):
|
|
199
|
+
parameters = ssm_client.get_parameters_by_path(
|
|
200
|
+
Path=f"/copilot/applications/{application.name}/codebases",
|
|
201
|
+
Recursive=True,
|
|
202
|
+
)["Parameters"]
|
|
203
|
+
|
|
204
|
+
codebases = [json.loads(p["Value"]) for p in parameters]
|
|
205
|
+
|
|
206
|
+
if not codebases:
|
|
207
|
+
# TODO Is this really an error? Or just no codebases so we could return an empty list?
|
|
208
|
+
raise NoCopilotCodebasesFoundError
|
|
209
|
+
return codebases
|
|
210
|
+
|
|
211
|
+
def __start_build_with_confirmation(
|
|
212
|
+
self,
|
|
213
|
+
confirm_fn,
|
|
214
|
+
codebuild_client,
|
|
215
|
+
get_build_url_from_arn_fn,
|
|
216
|
+
confirmation_message,
|
|
217
|
+
build_options,
|
|
218
|
+
):
|
|
219
|
+
if confirm_fn(confirmation_message):
|
|
220
|
+
build_arn = self.start_build_extraction_fn(codebuild_client, build_options)
|
|
221
|
+
return get_build_url_from_arn_fn(build_arn)
|
|
222
|
+
return None
|