dbt-platform-helper 12.5.1__py3-none-any.whl → 13.0.0__py3-none-any.whl
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/COMMANDS.md +45 -42
- dbt_platform_helper/commands/codebase.py +7 -10
- dbt_platform_helper/commands/conduit.py +2 -2
- dbt_platform_helper/commands/config.py +1 -1
- dbt_platform_helper/commands/environment.py +32 -18
- dbt_platform_helper/commands/notify.py +5 -3
- dbt_platform_helper/commands/pipeline.py +17 -11
- dbt_platform_helper/constants.py +3 -1
- dbt_platform_helper/domain/codebase.py +48 -36
- dbt_platform_helper/domain/conduit.py +10 -12
- dbt_platform_helper/domain/config_validator.py +42 -31
- dbt_platform_helper/domain/copilot_environment.py +133 -129
- dbt_platform_helper/domain/database_copy.py +38 -37
- dbt_platform_helper/domain/maintenance_page.py +243 -193
- dbt_platform_helper/domain/pipelines.py +60 -135
- dbt_platform_helper/domain/terraform_environment.py +7 -3
- dbt_platform_helper/providers/aws.py +5 -0
- dbt_platform_helper/providers/cloudformation.py +12 -1
- dbt_platform_helper/providers/config.py +12 -14
- dbt_platform_helper/providers/ecr.py +20 -0
- dbt_platform_helper/providers/files.py +1 -1
- dbt_platform_helper/providers/io.py +31 -0
- dbt_platform_helper/providers/load_balancers.py +29 -3
- dbt_platform_helper/providers/platform_config_schema.py +24 -22
- dbt_platform_helper/providers/terraform_manifest.py +120 -0
- dbt_platform_helper/providers/vpc.py +81 -32
- dbt_platform_helper/templates/COMMANDS.md.jinja +5 -3
- dbt_platform_helper/templates/environment-pipelines/main.tf +2 -2
- dbt_platform_helper/templates/environments/main.tf +3 -4
- dbt_platform_helper/utils/aws.py +16 -5
- dbt_platform_helper/utils/messages.py +2 -3
- {dbt_platform_helper-12.5.1.dist-info → dbt_platform_helper-13.0.0.dist-info}/METADATA +2 -2
- {dbt_platform_helper-12.5.1.dist-info → dbt_platform_helper-13.0.0.dist-info}/RECORD +36 -44
- dbt_platform_helper/templates/pipelines/codebase/manifest.yml +0 -56
- dbt_platform_helper/templates/pipelines/codebase/overrides/.gitignore +0 -12
- dbt_platform_helper/templates/pipelines/codebase/overrides/bin/override.ts +0 -8
- dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.deploy.yml +0 -29
- dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.image.yml +0 -48
- dbt_platform_helper/templates/pipelines/codebase/overrides/cdk.json +0 -20
- dbt_platform_helper/templates/pipelines/codebase/overrides/package-lock.json +0 -4232
- dbt_platform_helper/templates/pipelines/codebase/overrides/package.json +0 -27
- dbt_platform_helper/templates/pipelines/codebase/overrides/stack.ts +0 -521
- dbt_platform_helper/templates/pipelines/codebase/overrides/tsconfig.json +0 -30
- dbt_platform_helper/templates/pipelines/codebase/overrides/types.ts +0 -52
- {dbt_platform_helper-12.5.1.dist-info → dbt_platform_helper-13.0.0.dist-info}/LICENSE +0 -0
- {dbt_platform_helper-12.5.1.dist-info → dbt_platform_helper-13.0.0.dist-info}/WHEEL +0 -0
- {dbt_platform_helper-12.5.1.dist-info → dbt_platform_helper-13.0.0.dist-info}/entry_points.txt +0 -0
dbt_platform_helper/COMMANDS.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
# Commands Reference
|
|
2
2
|
|
|
3
3
|
- [platform-helper](#platform-helper)
|
|
4
|
-
- [platform-helper application](#platform-helper-application)
|
|
5
|
-
- [platform-helper application container-stats](#platform-helper-application-container-stats)
|
|
6
|
-
- [platform-helper application task-stats](#platform-helper-application-task-stats)
|
|
7
|
-
- [platform-helper codebase](#platform-helper-codebase)
|
|
8
|
-
- [platform-helper codebase prepare](#platform-helper-codebase-prepare)
|
|
9
|
-
- [platform-helper codebase list](#platform-helper-codebase-list)
|
|
10
|
-
- [platform-helper codebase build](#platform-helper-codebase-build)
|
|
11
|
-
- [platform-helper codebase deploy](#platform-helper-codebase-deploy)
|
|
12
|
-
- [platform-helper conduit](#platform-helper-conduit)
|
|
13
|
-
- [platform-helper config](#platform-helper-config)
|
|
14
|
-
- [platform-helper config validate](#platform-helper-config-validate)
|
|
15
|
-
- [platform-helper config aws](#platform-helper-config-aws)
|
|
16
|
-
- [platform-helper copilot](#platform-helper-copilot)
|
|
17
|
-
- [platform-helper copilot make-addons](#platform-helper-copilot-make-addons)
|
|
18
|
-
- [platform-helper environment](#platform-helper-environment)
|
|
19
|
-
- [platform-helper environment offline](#platform-helper-environment-offline)
|
|
20
|
-
- [platform-helper environment online](#platform-helper-environment-online)
|
|
21
|
-
- [platform-helper environment generate](#platform-helper-environment-generate)
|
|
22
|
-
- [platform-helper environment generate-terraform](#platform-helper-environment-generate-terraform)
|
|
23
|
-
- [platform-helper generate](#platform-helper-generate)
|
|
24
|
-
- [platform-helper pipeline](#platform-helper-pipeline)
|
|
25
|
-
- [platform-helper pipeline generate](#platform-helper-pipeline-generate)
|
|
26
|
-
- [platform-helper secrets](#platform-helper-secrets)
|
|
27
|
-
- [platform-helper secrets copy](#platform-helper-secrets-copy)
|
|
28
|
-
- [platform-helper secrets list](#platform-helper-secrets-list)
|
|
29
|
-
- [platform-helper notify](#platform-helper-notify)
|
|
30
|
-
- [platform-helper notify environment-progress](#platform-helper-notify-environment-progress)
|
|
31
|
-
- [platform-helper notify add-comment](#platform-helper-notify-add-comment)
|
|
32
|
-
- [platform-helper database](#platform-helper-database)
|
|
33
|
-
- [platform-helper database dump](#platform-helper-database-dump)
|
|
34
|
-
- [platform-helper database load](#platform-helper-database-load)
|
|
35
|
-
- [platform-helper database copy](#platform-helper-database-copy)
|
|
36
|
-
- [platform-helper version](#platform-helper-version)
|
|
37
|
-
- [platform-helper version get-platform-helper-for-project](#platform-helper-version-get-platform-helper-for-project)
|
|
4
|
+
- [platform-helper application](#platform-helper-application)
|
|
5
|
+
- [platform-helper application container-stats](#platform-helper-application-container-stats)
|
|
6
|
+
- [platform-helper application task-stats](#platform-helper-application-task-stats)
|
|
7
|
+
- [platform-helper codebase](#platform-helper-codebase)
|
|
8
|
+
- [platform-helper codebase prepare](#platform-helper-codebase-prepare)
|
|
9
|
+
- [platform-helper codebase list](#platform-helper-codebase-list)
|
|
10
|
+
- [platform-helper codebase build](#platform-helper-codebase-build)
|
|
11
|
+
- [platform-helper codebase deploy](#platform-helper-codebase-deploy)
|
|
12
|
+
- [platform-helper conduit](#platform-helper-conduit)
|
|
13
|
+
- [platform-helper config](#platform-helper-config)
|
|
14
|
+
- [platform-helper config validate](#platform-helper-config-validate)
|
|
15
|
+
- [platform-helper config aws](#platform-helper-config-aws)
|
|
16
|
+
- [platform-helper copilot](#platform-helper-copilot)
|
|
17
|
+
- [platform-helper copilot make-addons](#platform-helper-copilot-make-addons)
|
|
18
|
+
- [platform-helper environment](#platform-helper-environment)
|
|
19
|
+
- [platform-helper environment offline](#platform-helper-environment-offline)
|
|
20
|
+
- [platform-helper environment online](#platform-helper-environment-online)
|
|
21
|
+
- [platform-helper environment generate](#platform-helper-environment-generate)
|
|
22
|
+
- [platform-helper environment generate-terraform](#platform-helper-environment-generate-terraform)
|
|
23
|
+
- [platform-helper generate](#platform-helper-generate)
|
|
24
|
+
- [platform-helper pipeline](#platform-helper-pipeline)
|
|
25
|
+
- [platform-helper pipeline generate](#platform-helper-pipeline-generate)
|
|
26
|
+
- [platform-helper secrets](#platform-helper-secrets)
|
|
27
|
+
- [platform-helper secrets copy](#platform-helper-secrets-copy)
|
|
28
|
+
- [platform-helper secrets list](#platform-helper-secrets-list)
|
|
29
|
+
- [platform-helper notify](#platform-helper-notify)
|
|
30
|
+
- [platform-helper notify environment-progress](#platform-helper-notify-environment-progress)
|
|
31
|
+
- [platform-helper notify add-comment](#platform-helper-notify-add-comment)
|
|
32
|
+
- [platform-helper database](#platform-helper-database)
|
|
33
|
+
- [platform-helper database dump](#platform-helper-database-dump)
|
|
34
|
+
- [platform-helper database load](#platform-helper-database-load)
|
|
35
|
+
- [platform-helper database copy](#platform-helper-database-copy)
|
|
36
|
+
- [platform-helper version](#platform-helper-version)
|
|
37
|
+
- [platform-helper version get-platform-helper-for-project](#platform-helper-version-get-platform-helper-for-project)
|
|
38
38
|
|
|
39
39
|
# platform-helper
|
|
40
40
|
|
|
@@ -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 platform-config.yml file
|
|
225
|
+
- The codebase name as specified in the platform-config.yml file. This must be run from your codebase repository directory.
|
|
226
226
|
- `--commit <text>`
|
|
227
227
|
- GitHub commit hash
|
|
228
228
|
- `--help <boolean>` _Defaults to False._
|
|
@@ -246,7 +246,7 @@ platform-helper codebase deploy --app <application> --env <environment> --codeba
|
|
|
246
246
|
- `--env <text>`
|
|
247
247
|
- AWS Copilot environment
|
|
248
248
|
- `--codebase <text>`
|
|
249
|
-
- The codebase name as specified in the platform-config.yml file
|
|
249
|
+
- The codebase name as specified in the platform-config.yml file. This can be run from any directory.
|
|
250
250
|
- `--commit <text>`
|
|
251
251
|
- GitHub commit hash
|
|
252
252
|
- `--help <boolean>` _Defaults to False._
|
|
@@ -457,6 +457,9 @@ platform-helper environment online --app <application> --env <environment>
|
|
|
457
457
|
|
|
458
458
|
[↩ Parent](#platform-helper-environment)
|
|
459
459
|
|
|
460
|
+
Gathers various IDs and ARNs from AWS and generates the AWS Copilot
|
|
461
|
+
environment manifest at copilot/environments/<environment>/manifest.yml.
|
|
462
|
+
|
|
460
463
|
## Usage
|
|
461
464
|
|
|
462
465
|
```
|
|
@@ -467,7 +470,7 @@ platform-helper environment generate --name <name>
|
|
|
467
470
|
|
|
468
471
|
- `--name
|
|
469
472
|
-n <text>`
|
|
470
|
-
|
|
473
|
+
- The name of the environment to generate a copilot manifest for.
|
|
471
474
|
- `--help <boolean>` _Defaults to False._
|
|
472
475
|
- Show this message and exit.
|
|
473
476
|
|
|
@@ -489,7 +492,7 @@ platform-helper environment generate-terraform --name <name> [--terraform-platfo
|
|
|
489
492
|
-n <text>`
|
|
490
493
|
- The name of the environment to generate a manifest for.
|
|
491
494
|
- `--terraform-platform-modules-version <text>`
|
|
492
|
-
- Override the default version of terraform-platform-modules. (Default version is '
|
|
495
|
+
- Override the default version of terraform-platform-modules. (Default version is '7').
|
|
493
496
|
- `--help <boolean>` _Defaults to False._
|
|
494
497
|
- Show this message and exit.
|
|
495
498
|
|
|
@@ -562,7 +565,7 @@ platform-helper pipeline generate [--terraform-platform-modules-version <terrafo
|
|
|
562
565
|
- Override the default version of terraform-platform-modules with a specific version or branch.
|
|
563
566
|
Precedence of version used is version supplied via CLI, then the version found in
|
|
564
567
|
platform-config.yml/default_versions/terraform-platform-modules.
|
|
565
|
-
In absence of these inputs, defaults to version '
|
|
568
|
+
In absence of these inputs, defaults to version '7'.
|
|
566
569
|
- `--deploy-branch <text>`
|
|
567
570
|
- Specify the branch of <application>-deploy used to configure the source stage in the environment-pipeline resource.
|
|
568
571
|
This is generated from the terraform/environments-pipeline/<aws_account>/main.tf file.
|
|
@@ -664,7 +667,7 @@ platform-helper notify (environment-progress|add-comment)
|
|
|
664
667
|
|
|
665
668
|
[↩ Parent](#platform-helper-notify)
|
|
666
669
|
|
|
667
|
-
Send environment progress notifications
|
|
670
|
+
Send environment progress notifications. This creates (or updates if --slack-ref is provided) the top level message to the channel.
|
|
668
671
|
|
|
669
672
|
## Usage
|
|
670
673
|
|
|
@@ -692,7 +695,7 @@ platform-helper notify environment-progress <slack_channel_id> <slack_token>
|
|
|
692
695
|
- `--commit-sha <text>`
|
|
693
696
|
|
|
694
697
|
- `--slack-ref <text>`
|
|
695
|
-
- Slack message reference
|
|
698
|
+
- Slack message reference of the message to update
|
|
696
699
|
- `--help <boolean>` _Defaults to False._
|
|
697
700
|
- Show this message and exit.
|
|
698
701
|
|
|
@@ -700,7 +703,7 @@ platform-helper notify environment-progress <slack_channel_id> <slack_token>
|
|
|
700
703
|
|
|
701
704
|
[↩ Parent](#platform-helper-notify)
|
|
702
705
|
|
|
703
|
-
Add comment to
|
|
706
|
+
Add a comment to an existing Slack message
|
|
704
707
|
|
|
705
708
|
## Usage
|
|
706
709
|
|
|
@@ -2,6 +2,7 @@ import click
|
|
|
2
2
|
|
|
3
3
|
from dbt_platform_helper.domain.codebase import Codebase
|
|
4
4
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
5
6
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
6
7
|
from dbt_platform_helper.utils.versioning import (
|
|
7
8
|
check_platform_helper_version_needs_update,
|
|
@@ -20,8 +21,7 @@ def prepare():
|
|
|
20
21
|
try:
|
|
21
22
|
Codebase().prepare()
|
|
22
23
|
except PlatformException as err:
|
|
23
|
-
|
|
24
|
-
raise click.Abort
|
|
24
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
@codebase.command()
|
|
@@ -37,15 +37,14 @@ def list(app, with_images):
|
|
|
37
37
|
try:
|
|
38
38
|
Codebase().list(app, with_images)
|
|
39
39
|
except PlatformException as err:
|
|
40
|
-
|
|
41
|
-
raise click.Abort
|
|
40
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
42
41
|
|
|
43
42
|
|
|
44
43
|
@codebase.command()
|
|
45
44
|
@click.option("--app", help="AWS application name", required=True)
|
|
46
45
|
@click.option(
|
|
47
46
|
"--codebase",
|
|
48
|
-
help="The codebase name as specified in the platform-config.yml file",
|
|
47
|
+
help="The codebase name as specified in the platform-config.yml file. This must be run from your codebase repository directory.",
|
|
49
48
|
required=True,
|
|
50
49
|
)
|
|
51
50
|
@click.option("--commit", help="GitHub commit hash", required=True)
|
|
@@ -54,8 +53,7 @@ def build(app, codebase, commit):
|
|
|
54
53
|
try:
|
|
55
54
|
Codebase().build(app, codebase, commit)
|
|
56
55
|
except PlatformException as err:
|
|
57
|
-
|
|
58
|
-
raise click.Abort
|
|
56
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
@codebase.command()
|
|
@@ -63,7 +61,7 @@ def build(app, codebase, commit):
|
|
|
63
61
|
@click.option("--env", help="AWS Copilot environment", required=True)
|
|
64
62
|
@click.option(
|
|
65
63
|
"--codebase",
|
|
66
|
-
help="The codebase name as specified in the platform-config.yml file",
|
|
64
|
+
help="The codebase name as specified in the platform-config.yml file. This can be run from any directory.",
|
|
67
65
|
required=True,
|
|
68
66
|
)
|
|
69
67
|
@click.option("--commit", help="GitHub commit hash", required=True)
|
|
@@ -71,5 +69,4 @@ def deploy(app, env, codebase, commit):
|
|
|
71
69
|
try:
|
|
72
70
|
Codebase().deploy(app, env, codebase, commit)
|
|
73
71
|
except PlatformException as err:
|
|
74
|
-
|
|
75
|
-
raise click.Abort
|
|
72
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -4,6 +4,7 @@ from dbt_platform_helper.domain.conduit import Conduit
|
|
|
4
4
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
5
|
from dbt_platform_helper.providers.cloudformation import CloudFormation
|
|
6
6
|
from dbt_platform_helper.providers.ecs import ECS
|
|
7
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
7
8
|
from dbt_platform_helper.providers.secrets import Secrets
|
|
8
9
|
from dbt_platform_helper.utils.application import load_application
|
|
9
10
|
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
@@ -54,5 +55,4 @@ def conduit(addon_name: str, app: str, env: str, access: str):
|
|
|
54
55
|
env, addon_name, access
|
|
55
56
|
)
|
|
56
57
|
except PlatformException as err:
|
|
57
|
-
|
|
58
|
-
raise click.Abort
|
|
58
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import click
|
|
2
|
-
from schema import SchemaError
|
|
3
2
|
|
|
4
3
|
from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
|
|
5
|
-
from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
|
|
6
4
|
from dbt_platform_helper.domain.config_validator import ConfigValidator
|
|
7
5
|
from dbt_platform_helper.domain.copilot_environment import CopilotEnvironment
|
|
8
6
|
from dbt_platform_helper.domain.maintenance_page import MaintenancePage
|
|
9
7
|
from dbt_platform_helper.domain.terraform_environment import TerraformEnvironment
|
|
10
8
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
9
|
+
from dbt_platform_helper.providers.cloudformation import CloudFormation
|
|
11
10
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
11
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
12
|
+
from dbt_platform_helper.providers.vpc import VpcProvider
|
|
13
|
+
from dbt_platform_helper.utils.application import load_application
|
|
14
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
12
15
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
13
16
|
from dbt_platform_helper.utils.versioning import (
|
|
14
17
|
check_platform_helper_version_needs_update,
|
|
@@ -36,11 +39,12 @@ def environment():
|
|
|
36
39
|
@click.option("--vpc", type=str)
|
|
37
40
|
def offline(app, env, svc, template, vpc):
|
|
38
41
|
"""Take load-balanced web services offline with a maintenance page."""
|
|
42
|
+
|
|
39
43
|
try:
|
|
40
|
-
|
|
44
|
+
application = load_application(app)
|
|
45
|
+
MaintenancePage(application).activate(env, svc, template, vpc)
|
|
41
46
|
except PlatformException as err:
|
|
42
|
-
|
|
43
|
-
raise click.Abort
|
|
47
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
@environment.command()
|
|
@@ -48,26 +52,37 @@ def offline(app, env, svc, template, vpc):
|
|
|
48
52
|
@click.option("--env", type=str, required=True)
|
|
49
53
|
def online(app, env):
|
|
50
54
|
"""Remove a maintenance page from an environment."""
|
|
55
|
+
|
|
51
56
|
try:
|
|
52
|
-
|
|
57
|
+
application = load_application(app)
|
|
58
|
+
MaintenancePage(application).deactivate(env)
|
|
53
59
|
except PlatformException as err:
|
|
54
|
-
|
|
55
|
-
raise click.Abort
|
|
60
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
56
61
|
|
|
57
62
|
|
|
58
63
|
@environment.command()
|
|
59
|
-
@click.option(
|
|
64
|
+
@click.option(
|
|
65
|
+
"--name",
|
|
66
|
+
"-n",
|
|
67
|
+
required=True,
|
|
68
|
+
help="The name of the environment to generate a copilot manifest for.",
|
|
69
|
+
)
|
|
60
70
|
def generate(name):
|
|
71
|
+
"""Gathers various IDs and ARNs from AWS and generates the AWS Copilot
|
|
72
|
+
environment manifest at copilot/environments/<environment>/manifest.yml."""
|
|
73
|
+
|
|
74
|
+
click_io = ClickIOProvider()
|
|
61
75
|
try:
|
|
76
|
+
session = get_aws_session_or_abort()
|
|
62
77
|
config_provider = ConfigProvider(ConfigValidator())
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
vpc_provider = VpcProvider(session)
|
|
79
|
+
cloudformation_provider = CloudFormation(session.client("cloudformation"))
|
|
80
|
+
|
|
81
|
+
CopilotEnvironment(
|
|
82
|
+
config_provider, vpc_provider, cloudformation_provider, session
|
|
83
|
+
).generate(name)
|
|
68
84
|
except PlatformException as err:
|
|
69
|
-
|
|
70
|
-
raise click.Abort
|
|
85
|
+
click_io.abort_with_error(str(err))
|
|
71
86
|
|
|
72
87
|
|
|
73
88
|
@environment.command(help="Generate terraform manifest for the specified environment.")
|
|
@@ -84,5 +99,4 @@ def generate_terraform(name, terraform_platform_modules_version):
|
|
|
84
99
|
config_provider = ConfigProvider(ConfigValidator())
|
|
85
100
|
TerraformEnvironment(config_provider).generate(name, terraform_platform_modules_version)
|
|
86
101
|
except PlatformException as err:
|
|
87
|
-
|
|
88
|
-
raise click.Abort
|
|
102
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -14,14 +14,16 @@ def notify():
|
|
|
14
14
|
check_platform_helper_version_needs_update()
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@notify.command(
|
|
17
|
+
@notify.command(
|
|
18
|
+
help="Send environment progress notifications. This creates (or updates if --slack-ref is provided) the top level message to the channel."
|
|
19
|
+
)
|
|
18
20
|
@click.argument("slack-channel-id")
|
|
19
21
|
@click.argument("slack-token")
|
|
20
22
|
@click.argument("message")
|
|
21
23
|
@click.option("--build-arn")
|
|
22
24
|
@click.option("--repository")
|
|
23
25
|
@click.option("--commit-sha")
|
|
24
|
-
@click.option("--slack-ref", help="Slack message reference")
|
|
26
|
+
@click.option("--slack-ref", help="Slack message reference of the message to update")
|
|
25
27
|
def environment_progress(
|
|
26
28
|
slack_channel_id: str,
|
|
27
29
|
slack_token: str,
|
|
@@ -83,7 +85,7 @@ def _get_slack_client(token: str):
|
|
|
83
85
|
return WebClient(token=token)
|
|
84
86
|
|
|
85
87
|
|
|
86
|
-
@notify.command(help="Add comment to
|
|
88
|
+
@notify.command(help="Add a comment to an existing Slack message")
|
|
87
89
|
@click.argument("slack-channel-id")
|
|
88
90
|
@click.argument("slack-token")
|
|
89
91
|
@click.argument("slack-ref")
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
3
2
|
import click
|
|
4
3
|
|
|
5
4
|
from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
|
|
6
5
|
from dbt_platform_helper.domain.config_validator import ConfigValidator
|
|
7
6
|
from dbt_platform_helper.domain.pipelines import Pipelines
|
|
8
7
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
8
|
+
from dbt_platform_helper.providers.ecr import ECRProvider
|
|
9
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
10
|
+
from dbt_platform_helper.providers.terraform_manifest import TerraformManifestProvider
|
|
9
11
|
from dbt_platform_helper.utils.aws import get_codestar_connection_arn
|
|
10
12
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
11
13
|
from dbt_platform_helper.utils.git import git_remote
|
|
12
|
-
from dbt_platform_helper.utils.messages import abort_with_error
|
|
13
14
|
from dbt_platform_helper.utils.versioning import (
|
|
14
15
|
check_platform_helper_version_needs_update,
|
|
15
16
|
)
|
|
@@ -37,7 +38,7 @@ def pipeline():
|
|
|
37
38
|
<application>-deploy/platform-config.yml/environment_pipelines/<environment-pipeline>/branch).""",
|
|
38
39
|
default=None,
|
|
39
40
|
)
|
|
40
|
-
def generate(terraform_platform_modules_version, deploy_branch):
|
|
41
|
+
def generate(terraform_platform_modules_version: str, deploy_branch: str):
|
|
41
42
|
"""
|
|
42
43
|
Given a platform-config.yml file, generate environment and service
|
|
43
44
|
deployment pipelines.
|
|
@@ -50,11 +51,16 @@ def generate(terraform_platform_modules_version, deploy_branch):
|
|
|
50
51
|
This command does the following in relation to the codebase pipelines:
|
|
51
52
|
- Generates the copilot pipeline manifest.yml for copilot/pipelines/<codebase_pipeline_name>
|
|
52
53
|
"""
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
io = ClickIOProvider()
|
|
55
|
+
try:
|
|
56
|
+
pipelines = Pipelines(
|
|
57
|
+
ConfigProvider(ConfigValidator()),
|
|
58
|
+
TerraformManifestProvider(),
|
|
59
|
+
ECRProvider(),
|
|
60
|
+
git_remote,
|
|
61
|
+
get_codestar_connection_arn,
|
|
62
|
+
io,
|
|
63
|
+
)
|
|
64
|
+
pipelines.generate(terraform_platform_modules_version, deploy_branch)
|
|
65
|
+
except Exception as exc:
|
|
66
|
+
io.abort_with_error(str(exc))
|
dbt_platform_helper/constants.py
CHANGED
|
@@ -3,7 +3,9 @@ PLATFORM_CONFIG_FILE = "platform-config.yml"
|
|
|
3
3
|
# Todo: Can we get rid of this yet?
|
|
4
4
|
PLATFORM_HELPER_VERSION_FILE = ".platform-helper-version"
|
|
5
5
|
# Todo: Move to ???
|
|
6
|
-
DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION = "
|
|
6
|
+
DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION = "7"
|
|
7
|
+
SUPPORTED_TERRAFORM_VERSION = "~> 1.8"
|
|
8
|
+
SUPPORTED_AWS_PROVIDER_VERSION = "~> 5"
|
|
7
9
|
|
|
8
10
|
# Keys
|
|
9
11
|
CODEBASE_PIPELINES_KEY = "codebase_pipelines"
|
|
@@ -4,22 +4,23 @@ import subprocess
|
|
|
4
4
|
from collections.abc import Callable
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
-
import click
|
|
8
7
|
import requests
|
|
9
8
|
import yaml
|
|
10
9
|
from boto3 import Session
|
|
11
10
|
|
|
12
11
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
13
12
|
from dbt_platform_helper.providers.files import FileProvider
|
|
13
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
14
14
|
from dbt_platform_helper.utils.application import Application
|
|
15
15
|
from dbt_platform_helper.utils.application import ApplicationException
|
|
16
16
|
from dbt_platform_helper.utils.application import load_application
|
|
17
|
-
from dbt_platform_helper.utils.aws import check_codebase_exists
|
|
18
17
|
from dbt_platform_helper.utils.aws import check_image_exists
|
|
19
18
|
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
20
19
|
from dbt_platform_helper.utils.aws import get_build_url_from_arn
|
|
20
|
+
from dbt_platform_helper.utils.aws import get_build_url_from_pipeline_execution_id
|
|
21
21
|
from dbt_platform_helper.utils.aws import list_latest_images
|
|
22
22
|
from dbt_platform_helper.utils.aws import start_build_extraction
|
|
23
|
+
from dbt_platform_helper.utils.aws import start_pipeline_and_return_execution_id
|
|
23
24
|
from dbt_platform_helper.utils.git import check_if_commit_exists
|
|
24
25
|
from dbt_platform_helper.utils.template import setup_templates
|
|
25
26
|
|
|
@@ -27,29 +28,31 @@ from dbt_platform_helper.utils.template import setup_templates
|
|
|
27
28
|
class Codebase:
|
|
28
29
|
def __init__(
|
|
29
30
|
self,
|
|
30
|
-
|
|
31
|
-
echo: Callable[[str], str] = click.secho,
|
|
32
|
-
confirm: Callable[[str], bool] = click.confirm,
|
|
31
|
+
io: ClickIOProvider = ClickIOProvider(),
|
|
33
32
|
load_application: Callable[[str], Application] = load_application,
|
|
34
33
|
get_aws_session_or_abort: Callable[[str], Session] = get_aws_session_or_abort,
|
|
35
|
-
check_codebase_exists: Callable[[str], str] = check_codebase_exists,
|
|
36
34
|
check_image_exists: Callable[[str], str] = check_image_exists,
|
|
37
35
|
get_build_url_from_arn: Callable[[str], str] = get_build_url_from_arn,
|
|
36
|
+
get_build_url_from_pipeline_execution_id: Callable[
|
|
37
|
+
[str], str
|
|
38
|
+
] = get_build_url_from_pipeline_execution_id,
|
|
38
39
|
list_latest_images: Callable[[str], str] = list_latest_images,
|
|
39
40
|
start_build_extraction: Callable[[str], str] = start_build_extraction,
|
|
41
|
+
start_pipeline_and_return_execution_id: Callable[
|
|
42
|
+
[str], str
|
|
43
|
+
] = start_pipeline_and_return_execution_id,
|
|
40
44
|
check_if_commit_exists: Callable[[str], str] = check_if_commit_exists,
|
|
41
45
|
run_subprocess: Callable[[str], str] = subprocess.run,
|
|
42
46
|
):
|
|
43
|
-
self.
|
|
44
|
-
self.echo = echo
|
|
45
|
-
self.confirm = confirm
|
|
47
|
+
self.io = io
|
|
46
48
|
self.load_application = load_application
|
|
47
49
|
self.get_aws_session_or_abort = get_aws_session_or_abort
|
|
48
|
-
self.check_codebase_exists = check_codebase_exists
|
|
49
50
|
self.check_image_exists = check_image_exists
|
|
50
51
|
self.get_build_url_from_arn = get_build_url_from_arn
|
|
52
|
+
self.get_build_url_from_pipeline_execution_id = get_build_url_from_pipeline_execution_id
|
|
51
53
|
self.list_latest_images = list_latest_images
|
|
52
54
|
self.start_build_extraction = start_build_extraction
|
|
55
|
+
self.start_pipeline_and_return_execution_id = start_pipeline_and_return_execution_id
|
|
53
56
|
self.check_if_commit_exists = check_if_commit_exists
|
|
54
57
|
self.run_subprocess = run_subprocess
|
|
55
58
|
|
|
@@ -91,7 +94,7 @@ class Codebase:
|
|
|
91
94
|
config_contents = templates.get_template(f".copilot/config.yml").render(
|
|
92
95
|
repository=repository, builder_version=builder_version
|
|
93
96
|
)
|
|
94
|
-
self.
|
|
97
|
+
self.io.info(
|
|
95
98
|
FileProvider.mkfile(
|
|
96
99
|
Path("."), ".copilot/image_build_run.sh", image_build_run_contents, overwrite=True
|
|
97
100
|
)
|
|
@@ -100,14 +103,14 @@ class Codebase:
|
|
|
100
103
|
image_build_run_file = Path(".copilot/image_build_run.sh")
|
|
101
104
|
image_build_run_file.chmod(image_build_run_file.stat().st_mode | stat.S_IEXEC)
|
|
102
105
|
|
|
103
|
-
self.
|
|
106
|
+
self.io.info(
|
|
104
107
|
FileProvider.mkfile(Path("."), ".copilot/config.yml", config_contents, overwrite=True)
|
|
105
108
|
)
|
|
106
109
|
|
|
107
110
|
for phase in ["build", "install", "post_build", "pre_build"]:
|
|
108
111
|
phase_contents = templates.get_template(f".copilot/phases/{phase}.sh").render()
|
|
109
112
|
|
|
110
|
-
self.
|
|
113
|
+
self.io.info(
|
|
111
114
|
FileProvider.mkfile(
|
|
112
115
|
Path("./.copilot"), f"phases/{phase}.sh", phase_contents, overwrite=True
|
|
113
116
|
)
|
|
@@ -122,19 +125,18 @@ class Codebase:
|
|
|
122
125
|
|
|
123
126
|
codebuild_client = session.client("codebuild")
|
|
124
127
|
build_url = self.__start_build_with_confirmation(
|
|
125
|
-
self.confirm,
|
|
126
128
|
codebuild_client,
|
|
127
129
|
self.get_build_url_from_arn,
|
|
128
130
|
f'You are about to build "{app}" for "{codebase}" with commit "{commit}". Do you want to continue?',
|
|
129
131
|
{
|
|
130
|
-
"projectName": f"
|
|
132
|
+
"projectName": f"{app}-{codebase}-codebase-pipeline-image-build",
|
|
131
133
|
"artifactsOverride": {"type": "NO_ARTIFACTS"},
|
|
132
134
|
"sourceVersion": commit,
|
|
133
135
|
},
|
|
134
136
|
)
|
|
135
137
|
|
|
136
138
|
if build_url:
|
|
137
|
-
return self.
|
|
139
|
+
return self.io.info(
|
|
138
140
|
f"Your build has been triggered. Check your build progress in the AWS Console: {build_url}"
|
|
139
141
|
)
|
|
140
142
|
|
|
@@ -148,29 +150,26 @@ class Codebase:
|
|
|
148
150
|
if not application.environments.get(env):
|
|
149
151
|
raise ApplicationEnvironmentNotFoundException(env)
|
|
150
152
|
|
|
151
|
-
self.check_codebase_exists(session, application, codebase)
|
|
152
|
-
|
|
153
153
|
self.check_image_exists(session, application, codebase, commit)
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
pipeline_name = f"{app}-{codebase}-manual-release-pipeline"
|
|
156
|
+
codepipeline_client = session.client("codepipeline")
|
|
157
|
+
|
|
158
|
+
build_url = self.__start_pipeline_execution_with_confirmation(
|
|
159
|
+
codepipeline_client,
|
|
160
|
+
self.get_build_url_from_pipeline_execution_id,
|
|
161
|
+
f'You are about to deploy "{app}" for "{codebase}" with commit "{commit}" to the "{env}" environment using the "{pipeline_name}" deployment pipeline. Do you want to continue?',
|
|
161
162
|
{
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
"environmentVariablesOverride": [
|
|
166
|
-
{"name": "COPILOT_ENVIRONMENT", "value": env},
|
|
163
|
+
"name": pipeline_name,
|
|
164
|
+
"variables": [
|
|
165
|
+
{"name": "ENVIRONMENT", "value": env},
|
|
167
166
|
{"name": "IMAGE_TAG", "value": f"commit-{commit}"},
|
|
168
167
|
],
|
|
169
168
|
},
|
|
170
169
|
)
|
|
171
170
|
|
|
172
171
|
if build_url:
|
|
173
|
-
return self.
|
|
172
|
+
return self.io.info(
|
|
174
173
|
"Your deployment has been triggered. Check your build progress in the AWS Console: "
|
|
175
174
|
f"{build_url}",
|
|
176
175
|
)
|
|
@@ -185,19 +184,19 @@ class Codebase:
|
|
|
185
184
|
ecr_client = session.client("ecr")
|
|
186
185
|
codebases = self.__get_codebases(application, ssm_client)
|
|
187
186
|
|
|
188
|
-
self.
|
|
187
|
+
self.io.info("The following codebases are available:")
|
|
189
188
|
|
|
190
189
|
for codebase in codebases:
|
|
191
|
-
self.
|
|
190
|
+
self.io.info(f"- {codebase['name']} (https://github.com/{codebase['repository']})")
|
|
192
191
|
if with_images:
|
|
193
192
|
self.list_latest_images(
|
|
194
193
|
ecr_client,
|
|
195
194
|
f"{application.name}/{codebase['name']}",
|
|
196
195
|
codebase["repository"],
|
|
197
|
-
self.
|
|
196
|
+
self.io.info,
|
|
198
197
|
)
|
|
199
198
|
|
|
200
|
-
self.
|
|
199
|
+
self.io.info("")
|
|
201
200
|
|
|
202
201
|
def __get_codebases(self, application, ssm_client):
|
|
203
202
|
parameters = ssm_client.get_parameters_by_path(
|
|
@@ -213,17 +212,30 @@ class Codebase:
|
|
|
213
212
|
|
|
214
213
|
def __start_build_with_confirmation(
|
|
215
214
|
self,
|
|
216
|
-
confirm,
|
|
217
215
|
codebuild_client,
|
|
218
216
|
get_build_url_from_arn,
|
|
219
217
|
confirmation_message,
|
|
220
218
|
build_options,
|
|
221
219
|
):
|
|
222
|
-
if confirm(confirmation_message):
|
|
220
|
+
if self.io.confirm(confirmation_message):
|
|
223
221
|
build_arn = self.start_build_extraction(codebuild_client, build_options)
|
|
224
222
|
return get_build_url_from_arn(build_arn)
|
|
225
223
|
return None
|
|
226
224
|
|
|
225
|
+
def __start_pipeline_execution_with_confirmation(
|
|
226
|
+
self,
|
|
227
|
+
codepipeline_client,
|
|
228
|
+
get_build_url_from_pipeline_execution_id,
|
|
229
|
+
confirmation_message,
|
|
230
|
+
build_options,
|
|
231
|
+
):
|
|
232
|
+
if self.io.confirm(confirmation_message):
|
|
233
|
+
execution_id = self.start_pipeline_and_return_execution_id(
|
|
234
|
+
codepipeline_client, build_options
|
|
235
|
+
)
|
|
236
|
+
return get_build_url_from_pipeline_execution_id(execution_id, build_options["name"])
|
|
237
|
+
return None
|
|
238
|
+
|
|
227
239
|
|
|
228
240
|
class ApplicationDeploymentNotTriggered(PlatformException):
|
|
229
241
|
def __init__(self, codebase: str):
|