dbt-platform-helper 13.1.2__py3-none-any.whl → 13.3.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/application.py +2 -4
- dbt_platform_helper/commands/codebase.py +11 -7
- dbt_platform_helper/commands/conduit.py +1 -3
- dbt_platform_helper/commands/config.py +12 -314
- dbt_platform_helper/commands/copilot.py +14 -8
- dbt_platform_helper/commands/database.py +17 -9
- dbt_platform_helper/commands/environment.py +5 -6
- dbt_platform_helper/commands/generate.py +2 -3
- dbt_platform_helper/commands/notify.py +1 -3
- dbt_platform_helper/commands/pipeline.py +1 -3
- dbt_platform_helper/commands/secrets.py +1 -3
- dbt_platform_helper/commands/version.py +2 -2
- dbt_platform_helper/domain/codebase.py +17 -9
- dbt_platform_helper/domain/config.py +345 -0
- dbt_platform_helper/domain/copilot.py +158 -157
- dbt_platform_helper/domain/maintenance_page.py +42 -15
- dbt_platform_helper/domain/pipelines.py +1 -1
- dbt_platform_helper/domain/terraform_environment.py +1 -1
- dbt_platform_helper/domain/versioning.py +161 -30
- dbt_platform_helper/providers/aws/__init__.py +0 -0
- dbt_platform_helper/providers/{aws.py → aws/exceptions.py} +10 -0
- dbt_platform_helper/providers/aws/interfaces.py +13 -0
- dbt_platform_helper/providers/aws/opensearch.py +23 -0
- dbt_platform_helper/providers/aws/redis.py +21 -0
- dbt_platform_helper/providers/aws/sso_auth.py +61 -0
- dbt_platform_helper/providers/cache.py +40 -4
- dbt_platform_helper/providers/config.py +2 -1
- dbt_platform_helper/providers/config_validator.py +28 -25
- dbt_platform_helper/providers/copilot.py +1 -1
- dbt_platform_helper/providers/io.py +5 -2
- dbt_platform_helper/providers/kms.py +22 -0
- dbt_platform_helper/providers/load_balancers.py +26 -15
- dbt_platform_helper/providers/parameter_store.py +47 -0
- dbt_platform_helper/providers/platform_config_schema.py +17 -0
- dbt_platform_helper/providers/semantic_version.py +18 -88
- dbt_platform_helper/providers/terraform_manifest.py +1 -0
- dbt_platform_helper/providers/version.py +102 -26
- dbt_platform_helper/providers/version_status.py +80 -0
- dbt_platform_helper/providers/yaml_file.py +0 -1
- dbt_platform_helper/utils/aws.py +24 -142
- dbt_platform_helper/utils/git.py +3 -1
- dbt_platform_helper/utils/tool_versioning.py +12 -0
- {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/METADATA +2 -2
- {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/RECORD +48 -47
- {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/WHEEL +1 -1
- platform_helper.py +1 -1
- dbt_platform_helper/providers/opensearch.py +0 -36
- dbt_platform_helper/providers/platform_helper_versioning.py +0 -107
- dbt_platform_helper/providers/redis.py +0 -34
- dbt_platform_helper/templates/svc/manifest-backend.yml +0 -69
- dbt_platform_helper/templates/svc/manifest-public.yml +0 -109
- dbt_platform_helper/utils/cloudfoundry.py +0 -14
- dbt_platform_helper/utils/files.py +0 -59
- dbt_platform_helper/utils/manifests.py +0 -18
- dbt_platform_helper/utils/versioning.py +0 -91
- {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/LICENSE +0 -0
- {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/entry_points.txt +0 -0
|
@@ -10,9 +10,7 @@ from datetime import timedelta
|
|
|
10
10
|
import click
|
|
11
11
|
from prettytable import PrettyTable
|
|
12
12
|
|
|
13
|
-
from dbt_platform_helper.
|
|
14
|
-
PlatformHelperVersioning,
|
|
15
|
-
)
|
|
13
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
16
14
|
from dbt_platform_helper.utils.application import load_application
|
|
17
15
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
18
16
|
|
|
@@ -141,7 +139,7 @@ def container_stats(env, app, storage, network):
|
|
|
141
139
|
storage_write = field[6]["value"]
|
|
142
140
|
network_read = field[7]["value"]
|
|
143
141
|
network_write = field[8]["value"]
|
|
144
|
-
cpu = "
|
|
142
|
+
cpu = f"{float(field[9]['value']):.1f}%"
|
|
145
143
|
memory = f"{field[10]['value']}M"
|
|
146
144
|
|
|
147
145
|
# Nothing to compare to at start.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from dbt_platform_helper.domain.codebase import Codebase
|
|
4
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
4
5
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
6
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
6
|
-
from dbt_platform_helper.providers.
|
|
7
|
-
|
|
8
|
-
)
|
|
7
|
+
from dbt_platform_helper.providers.parameter_store import ParameterStore
|
|
8
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
9
9
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
10
10
|
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ def codebase():
|
|
|
19
19
|
def prepare():
|
|
20
20
|
"""Sets up an application codebase for use within a DBT platform project."""
|
|
21
21
|
try:
|
|
22
|
-
Codebase().prepare()
|
|
22
|
+
Codebase(ParameterStore(get_aws_session_or_abort().client("ssm"))).prepare()
|
|
23
23
|
except PlatformException as err:
|
|
24
24
|
ClickIOProvider().abort_with_error(str(err))
|
|
25
25
|
|
|
@@ -35,7 +35,7 @@ def prepare():
|
|
|
35
35
|
def list(app, with_images):
|
|
36
36
|
"""List available codebases for the application."""
|
|
37
37
|
try:
|
|
38
|
-
Codebase().list(app, with_images)
|
|
38
|
+
Codebase(ParameterStore(get_aws_session_or_abort().client("ssm"))).list(app, with_images)
|
|
39
39
|
except PlatformException as err:
|
|
40
40
|
ClickIOProvider().abort_with_error(str(err))
|
|
41
41
|
|
|
@@ -51,7 +51,9 @@ def list(app, with_images):
|
|
|
51
51
|
def build(app, codebase, commit):
|
|
52
52
|
"""Trigger a CodePipeline pipeline based build."""
|
|
53
53
|
try:
|
|
54
|
-
Codebase().build(
|
|
54
|
+
Codebase(ParameterStore(get_aws_session_or_abort().client("ssm"))).build(
|
|
55
|
+
app, codebase, commit
|
|
56
|
+
)
|
|
55
57
|
except PlatformException as err:
|
|
56
58
|
ClickIOProvider().abort_with_error(str(err))
|
|
57
59
|
|
|
@@ -67,6 +69,8 @@ def build(app, codebase, commit):
|
|
|
67
69
|
@click.option("--commit", help="GitHub commit hash", required=True)
|
|
68
70
|
def deploy(app, env, codebase, commit):
|
|
69
71
|
try:
|
|
70
|
-
Codebase().deploy(
|
|
72
|
+
Codebase(ParameterStore(get_aws_session_or_abort().client("ssm"))).deploy(
|
|
73
|
+
app, env, codebase, commit
|
|
74
|
+
)
|
|
71
75
|
except PlatformException as err:
|
|
72
76
|
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from dbt_platform_helper.domain.conduit import Conduit
|
|
4
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
4
5
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
6
|
from dbt_platform_helper.providers.cloudformation import CloudFormation
|
|
6
7
|
from dbt_platform_helper.providers.ecs import ECS
|
|
7
8
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
8
|
-
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
9
|
-
PlatformHelperVersioning,
|
|
10
|
-
)
|
|
11
9
|
from dbt_platform_helper.providers.secrets import Secrets
|
|
12
10
|
from dbt_platform_helper.utils.application import load_application
|
|
13
11
|
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
@@ -1,56 +1,11 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import webbrowser
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Dict
|
|
5
|
-
|
|
6
|
-
import boto3
|
|
7
|
-
import botocore
|
|
8
1
|
import click
|
|
9
|
-
from prettytable import PrettyTable
|
|
10
2
|
|
|
11
|
-
from dbt_platform_helper.
|
|
3
|
+
from dbt_platform_helper.domain.config import Config
|
|
4
|
+
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
|
+
from dbt_platform_helper.providers.aws.sso_auth import SSOAuthProvider
|
|
12
6
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
13
|
-
from dbt_platform_helper.
|
|
14
|
-
IncompatibleMajorVersionException,
|
|
15
|
-
)
|
|
16
|
-
from dbt_platform_helper.providers.validation import ValidationException
|
|
17
|
-
from dbt_platform_helper.utils import versioning
|
|
7
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
18
8
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
19
|
-
from dbt_platform_helper.utils.versioning import get_platform_helper_version_status
|
|
20
|
-
|
|
21
|
-
yes = "\033[92m✔\033[0m"
|
|
22
|
-
no = "\033[91m✖\033[0m"
|
|
23
|
-
maybe = "\033[93m?\033[0m"
|
|
24
|
-
|
|
25
|
-
RECOMMENDATIONS = {
|
|
26
|
-
"dbt-platform-helper-upgrade": (
|
|
27
|
-
"Upgrade dbt-platform-helper to version {version} `pip install "
|
|
28
|
-
"--upgrade dbt-platform-helper=={version}`."
|
|
29
|
-
),
|
|
30
|
-
"dbt-platform-helper-upgrade-note": (
|
|
31
|
-
"Post upgrade, run `platform-helper copilot make-addons` to " "update your addon templates."
|
|
32
|
-
),
|
|
33
|
-
"generic-tool-upgrade": "Upgrade {tool} to version {version}.",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
SSO_START_URL = "https://uktrade.awsapps.com/start"
|
|
37
|
-
|
|
38
|
-
AWS_CONFIG = """
|
|
39
|
-
#
|
|
40
|
-
# uktrade
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
[sso-session uktrade]
|
|
44
|
-
sso_start_url = https://uktrade.awsapps.com/start#/
|
|
45
|
-
sso_region = eu-west-2
|
|
46
|
-
sso_registration_scopes = sso:account:access
|
|
47
|
-
|
|
48
|
-
[default]
|
|
49
|
-
sso_session = uktrade
|
|
50
|
-
region = eu-west-2
|
|
51
|
-
output = json
|
|
52
|
-
|
|
53
|
-
"""
|
|
54
9
|
|
|
55
10
|
|
|
56
11
|
@click.group(cls=ClickDocOptGroup)
|
|
@@ -61,190 +16,10 @@ def config():
|
|
|
61
16
|
@config.command()
|
|
62
17
|
def validate():
|
|
63
18
|
"""Validate deployment or application configuration."""
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ran_checks = True
|
|
69
|
-
|
|
70
|
-
if not ran_checks:
|
|
71
|
-
click.secho("Could not find a deployment repository, no checks to run.", fg="red")
|
|
72
|
-
exit(1)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def deployment():
|
|
76
|
-
click.secho()
|
|
77
|
-
|
|
78
|
-
compatible = True
|
|
79
|
-
platform_helper_version_status = get_platform_helper_version_status()
|
|
80
|
-
ClickIOProvider().process_messages(platform_helper_version_status.validate())
|
|
81
|
-
copilot_versions = versioning.get_copilot_versions()
|
|
82
|
-
aws_versions = versioning.get_aws_versions()
|
|
83
|
-
_check_tool_versions(platform_helper_version_status, copilot_versions, aws_versions)
|
|
84
|
-
click.secho("Checking addons templates versions...", fg="blue")
|
|
85
|
-
|
|
86
|
-
local_version = platform_helper_version_status.local
|
|
87
|
-
latest_release = platform_helper_version_status.latest
|
|
88
|
-
addons_templates_table = PrettyTable()
|
|
89
|
-
addons_templates_table.field_names = [
|
|
90
|
-
"Addons Template File",
|
|
91
|
-
"Generated with",
|
|
92
|
-
"Compatible with local?",
|
|
93
|
-
"Compatible with latest?",
|
|
94
|
-
]
|
|
95
|
-
addons_templates_table.align["Addons Template File"] = "l"
|
|
96
|
-
|
|
97
|
-
addons_templates = list(Path("./copilot").glob("**/addons/*"))
|
|
98
|
-
# Sort by template file path
|
|
99
|
-
addons_templates.sort(key=lambda e: str(e))
|
|
100
|
-
# Bring environment addons to the top
|
|
101
|
-
addons_templates.sort(key=lambda e: "environments/" not in str(e))
|
|
102
|
-
|
|
103
|
-
recommendations = {}
|
|
104
|
-
|
|
105
|
-
ConfigProvider().config_file_check()
|
|
106
|
-
|
|
107
|
-
for template_file in addons_templates:
|
|
108
|
-
generated_with_version = maybe
|
|
109
|
-
local_compatible_symbol = yes
|
|
110
|
-
latest_compatible_symbol = yes
|
|
111
|
-
|
|
112
|
-
try:
|
|
113
|
-
generated_with_version = versioning.get_template_generated_with_version(
|
|
114
|
-
str(template_file.resolve())
|
|
115
|
-
)
|
|
116
|
-
versioning.validate_template_version(local_version, str(template_file.resolve()))
|
|
117
|
-
except IncompatibleMajorVersionException:
|
|
118
|
-
local_compatible_symbol = no
|
|
119
|
-
compatible = False
|
|
120
|
-
recommendations["dbt-platform-helper-upgrade"] = RECOMMENDATIONS[
|
|
121
|
-
"dbt-platform-helper-upgrade"
|
|
122
|
-
].format(version=latest_release)
|
|
123
|
-
recommendations["dbt-platform-helper-upgrade-note"] = RECOMMENDATIONS[
|
|
124
|
-
"dbt-platform-helper-upgrade-note"
|
|
125
|
-
]
|
|
126
|
-
except ValidationException:
|
|
127
|
-
local_compatible_symbol = maybe
|
|
128
|
-
compatible = False
|
|
129
|
-
recommendations["dbt-platform-helper-upgrade"] = RECOMMENDATIONS[
|
|
130
|
-
"dbt-platform-helper-upgrade"
|
|
131
|
-
].format(version=latest_release)
|
|
132
|
-
recommendations["dbt-platform-helper-upgrade-note"] = RECOMMENDATIONS[
|
|
133
|
-
"dbt-platform-helper-upgrade-note"
|
|
134
|
-
]
|
|
135
|
-
|
|
136
|
-
try:
|
|
137
|
-
generated_with_version = versioning.get_template_generated_with_version(
|
|
138
|
-
str(template_file.resolve())
|
|
139
|
-
)
|
|
140
|
-
versioning.validate_template_version(latest_release, str(template_file.resolve()))
|
|
141
|
-
except IncompatibleMajorVersionException:
|
|
142
|
-
latest_compatible_symbol = no
|
|
143
|
-
compatible = False
|
|
144
|
-
except ValidationException:
|
|
145
|
-
latest_compatible_symbol = maybe
|
|
146
|
-
compatible = False
|
|
147
|
-
|
|
148
|
-
addons_templates_table.add_row(
|
|
149
|
-
[
|
|
150
|
-
template_file.relative_to("."),
|
|
151
|
-
(maybe if latest_compatible_symbol is maybe else str(generated_with_version)),
|
|
152
|
-
local_compatible_symbol,
|
|
153
|
-
latest_compatible_symbol,
|
|
154
|
-
]
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
click.secho(addons_templates_table)
|
|
158
|
-
render_recommendations(recommendations)
|
|
159
|
-
|
|
160
|
-
exit(0 if compatible else 1)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def _check_tool_versions(platform_helper_versions, copilot_versions, aws_versions):
|
|
164
|
-
click.secho("Checking tooling versions...", fg="blue")
|
|
165
|
-
recommendations = {}
|
|
166
|
-
|
|
167
|
-
local_copilot_version = copilot_versions.local
|
|
168
|
-
copilot_latest_release = copilot_versions.latest
|
|
169
|
-
if local_copilot_version is None:
|
|
170
|
-
recommendations["install-copilot"] = (
|
|
171
|
-
"Install AWS Copilot https://aws.github.io/copilot-cli/"
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
if aws_versions.local is None:
|
|
175
|
-
recommendations["install-aws"] = "Install AWS CLI https://aws.amazon.com/cli/"
|
|
176
|
-
|
|
177
|
-
tool_versions_table = PrettyTable()
|
|
178
|
-
tool_versions_table.field_names = [
|
|
179
|
-
"Tool",
|
|
180
|
-
"Local version",
|
|
181
|
-
"Released version",
|
|
182
|
-
"Running latest?",
|
|
183
|
-
]
|
|
184
|
-
tool_versions_table.align["Tool"] = "l"
|
|
185
|
-
|
|
186
|
-
tool_versions_table.add_row(
|
|
187
|
-
[
|
|
188
|
-
"aws",
|
|
189
|
-
str(aws_versions.local),
|
|
190
|
-
str(aws_versions.latest),
|
|
191
|
-
no if aws_versions.is_outdated() else yes,
|
|
192
|
-
]
|
|
193
|
-
)
|
|
194
|
-
tool_versions_table.add_row(
|
|
195
|
-
[
|
|
196
|
-
"copilot",
|
|
197
|
-
str(copilot_versions.local),
|
|
198
|
-
str(copilot_versions.latest),
|
|
199
|
-
no if copilot_versions.is_outdated() else yes,
|
|
200
|
-
]
|
|
201
|
-
)
|
|
202
|
-
tool_versions_table.add_row(
|
|
203
|
-
[
|
|
204
|
-
"dbt-platform-helper",
|
|
205
|
-
str(platform_helper_versions.local),
|
|
206
|
-
str(platform_helper_versions.latest),
|
|
207
|
-
no if platform_helper_versions.is_outdated() else yes,
|
|
208
|
-
]
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
click.secho(tool_versions_table)
|
|
212
|
-
|
|
213
|
-
if aws_versions.is_outdated() and "install-aws" not in recommendations:
|
|
214
|
-
recommendations["aws-upgrade"] = RECOMMENDATIONS["generic-tool-upgrade"].format(
|
|
215
|
-
tool="AWS CLI",
|
|
216
|
-
version=str(aws_versions.latest),
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
if copilot_versions.is_outdated() and "install-copilot" not in recommendations:
|
|
220
|
-
recommendations["copilot-upgrade"] = RECOMMENDATIONS["generic-tool-upgrade"].format(
|
|
221
|
-
tool="AWS Copilot",
|
|
222
|
-
version=str(copilot_latest_release),
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
if platform_helper_versions.is_outdated():
|
|
226
|
-
recommendations["dbt-platform-helper-upgrade"] = RECOMMENDATIONS[
|
|
227
|
-
"dbt-platform-helper-upgrade"
|
|
228
|
-
].format(version=str(platform_helper_versions.latest))
|
|
229
|
-
recommendations["dbt-platform-helper-upgrade-note"] = RECOMMENDATIONS[
|
|
230
|
-
"dbt-platform-helper-upgrade-note"
|
|
231
|
-
]
|
|
232
|
-
|
|
233
|
-
render_recommendations(recommendations)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def render_recommendations(recommendations: Dict[str, str]):
|
|
237
|
-
if recommendations:
|
|
238
|
-
click.secho("\nRecommendations:\n", bold=True)
|
|
239
|
-
|
|
240
|
-
for name, recommendation in recommendations.items():
|
|
241
|
-
if name.endswith("-note"):
|
|
242
|
-
continue
|
|
243
|
-
click.secho(f" - {recommendation}")
|
|
244
|
-
if recommendations.get(f"{name}-note", False):
|
|
245
|
-
click.secho(f" {recommendations.get(f'{name}-note')}")
|
|
246
|
-
|
|
247
|
-
click.secho()
|
|
19
|
+
try:
|
|
20
|
+
Config().validate()
|
|
21
|
+
except PlatformException as err:
|
|
22
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
248
23
|
|
|
249
24
|
|
|
250
25
|
@config.command()
|
|
@@ -256,85 +31,8 @@ def aws(file_path):
|
|
|
256
31
|
|
|
257
32
|
If no `--file-path` is specified, defaults to `~/.aws/config`.
|
|
258
33
|
"""
|
|
259
|
-
sso_oidc_client = boto3.client("sso-oidc", region_name="eu-west-2")
|
|
260
|
-
sso_client = boto3.client("sso", region_name="eu-west-2")
|
|
261
|
-
oidc_app = create_oidc_application(sso_oidc_client)
|
|
262
|
-
verification_url, device_code = get_device_code(sso_oidc_client, oidc_app, SSO_START_URL)
|
|
263
|
-
|
|
264
|
-
if click.confirm(
|
|
265
|
-
"You are about to be redirected to a verification page. You will need to complete sign-in before returning to the command line. Do you want to continue?",
|
|
266
|
-
abort=True,
|
|
267
|
-
):
|
|
268
|
-
webbrowser.open(verification_url)
|
|
269
|
-
|
|
270
|
-
if click.confirm("Have you completed the sign-in process in your browser?", abort=True):
|
|
271
|
-
access_token = get_access_token(device_code, sso_oidc_client, oidc_app)
|
|
272
|
-
|
|
273
|
-
aws_config_path = os.path.expanduser(file_path)
|
|
274
|
-
|
|
275
|
-
if click.confirm(
|
|
276
|
-
f"This command is destructive and will overwrite file contents at {file_path}. Are you sure you want to continue?",
|
|
277
|
-
abort=True,
|
|
278
|
-
):
|
|
279
|
-
with open(aws_config_path, "w") as config_file:
|
|
280
|
-
config_file.write(AWS_CONFIG)
|
|
281
|
-
|
|
282
|
-
for account in retrieve_aws_accounts(sso_client, access_token):
|
|
283
|
-
config_file.write(f"[profile {account['accountName']}]\n")
|
|
284
|
-
config_file.write("sso_session = uktrade\n")
|
|
285
|
-
config_file.write(f"sso_account_id = {account['accountId']}\n")
|
|
286
|
-
config_file.write("sso_role_name = AdministratorAccess\n")
|
|
287
|
-
config_file.write("region = eu-west-2\n")
|
|
288
|
-
config_file.write("output = json\n")
|
|
289
|
-
config_file.write("\n")
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
def create_oidc_application(sso_oidc_client):
|
|
293
|
-
print("Creating temporary AWS SSO OIDC application")
|
|
294
|
-
client = sso_oidc_client.register_client(
|
|
295
|
-
clientName="platform-helper",
|
|
296
|
-
clientType="public",
|
|
297
|
-
)
|
|
298
|
-
client_id = client.get("clientId")
|
|
299
|
-
client_secret = client.get("clientSecret")
|
|
300
|
-
|
|
301
|
-
return client_id, client_secret
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
def get_device_code(sso_oidc_client, oidc_application, start_url):
|
|
305
|
-
print("Initiating device code flow")
|
|
306
|
-
authz = sso_oidc_client.start_device_authorization(
|
|
307
|
-
clientId=oidc_application[0],
|
|
308
|
-
clientSecret=oidc_application[1],
|
|
309
|
-
startUrl=start_url,
|
|
310
|
-
)
|
|
311
|
-
url = authz.get("verificationUriComplete")
|
|
312
|
-
deviceCode = authz.get("deviceCode")
|
|
313
|
-
|
|
314
|
-
return url, deviceCode
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
def retrieve_aws_accounts(sso_client, aws_sso_token):
|
|
318
|
-
aws_accounts_response = sso_client.list_accounts(
|
|
319
|
-
accessToken=aws_sso_token,
|
|
320
|
-
maxResults=100,
|
|
321
|
-
)
|
|
322
|
-
if len(aws_accounts_response.get("accountList", [])) == 0:
|
|
323
|
-
raise RuntimeError("Unable to retrieve AWS SSO account list\n")
|
|
324
|
-
return aws_accounts_response.get("accountList")
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
def get_access_token(device_code, sso_oidc_client, oidc_app):
|
|
328
34
|
try:
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
deviceCode=device_code,
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
return token_response.get("accessToken")
|
|
337
|
-
|
|
338
|
-
except botocore.exceptions.ClientError as e:
|
|
339
|
-
if e.response["Error"]["Code"] != "AuthorizationPendingException":
|
|
340
|
-
raise e
|
|
35
|
+
session = get_aws_session_or_abort()
|
|
36
|
+
Config(sso=SSOAuthProvider(session)).generate_aws(file_path)
|
|
37
|
+
except PlatformException as err:
|
|
38
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -4,19 +4,16 @@ import click
|
|
|
4
4
|
|
|
5
5
|
from dbt_platform_helper.domain.copilot import Copilot
|
|
6
6
|
from dbt_platform_helper.domain.copilot_environment import CopilotTemplating
|
|
7
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
7
8
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
8
9
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
9
10
|
from dbt_platform_helper.providers.files import FileProvider
|
|
10
11
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
11
|
-
from dbt_platform_helper.providers.
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
from dbt_platform_helper.providers.kms import KMSProvider
|
|
13
|
+
from dbt_platform_helper.providers.parameter_store import ParameterStore
|
|
14
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
14
15
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
15
16
|
|
|
16
|
-
# TODOs
|
|
17
|
-
# Figure out a pattern for copilot templating and the new copilot domain - probably a lot of overlap here that really belongs in the copilottemplating domain instead (atleast whatever is concerned with "templating")
|
|
18
|
-
# Check for E2E test coverage.
|
|
19
|
-
|
|
20
17
|
|
|
21
18
|
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
22
19
|
def copilot():
|
|
@@ -27,7 +24,16 @@ def copilot():
|
|
|
27
24
|
def make_addons():
|
|
28
25
|
"""Generate addons CloudFormation for each environment."""
|
|
29
26
|
try:
|
|
27
|
+
session = get_aws_session_or_abort()
|
|
28
|
+
parameter_provider = ParameterStore(session.client("ssm"))
|
|
30
29
|
config_provider = ConfigProvider(ConfigValidator())
|
|
31
|
-
Copilot(
|
|
30
|
+
Copilot(
|
|
31
|
+
config_provider,
|
|
32
|
+
parameter_provider,
|
|
33
|
+
FileProvider(),
|
|
34
|
+
CopilotTemplating(),
|
|
35
|
+
KMSProvider,
|
|
36
|
+
session,
|
|
37
|
+
).make_addons()
|
|
32
38
|
except Exception as err:
|
|
33
39
|
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -2,6 +2,8 @@ import click
|
|
|
2
2
|
|
|
3
3
|
from dbt_platform_helper.commands.environment import AVAILABLE_TEMPLATES
|
|
4
4
|
from dbt_platform_helper.domain.database_copy import DatabaseCopy
|
|
5
|
+
from dbt_platform_helper.platform_exception import PlatformException
|
|
6
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
5
7
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
6
8
|
|
|
7
9
|
|
|
@@ -38,9 +40,11 @@ def database():
|
|
|
38
40
|
)
|
|
39
41
|
def dump(app, from_env, database, from_vpc, filename):
|
|
40
42
|
"""Dump a database into an S3 bucket."""
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
try:
|
|
44
|
+
data_copy = DatabaseCopy(app, database)
|
|
45
|
+
data_copy.dump(from_env, from_vpc, filename)
|
|
46
|
+
except PlatformException as err:
|
|
47
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
@database.command(name="load")
|
|
@@ -68,9 +72,11 @@ def dump(app, from_env, database, from_vpc, filename):
|
|
|
68
72
|
)
|
|
69
73
|
def load(app, to_env, database, to_vpc, auto_approve, filename):
|
|
70
74
|
"""Load a database from an S3 bucket."""
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
try:
|
|
76
|
+
data_copy = DatabaseCopy(app, database, auto_approve)
|
|
77
|
+
data_copy.load(to_env, to_vpc, filename)
|
|
78
|
+
except PlatformException as err:
|
|
79
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
74
80
|
|
|
75
81
|
|
|
76
82
|
@database.command(name="copy")
|
|
@@ -120,6 +126,8 @@ def copy(
|
|
|
120
126
|
no_maintenance_page,
|
|
121
127
|
):
|
|
122
128
|
"""Copy a database between environments."""
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
try:
|
|
130
|
+
data_copy = DatabaseCopy(app, database, auto_approve)
|
|
131
|
+
data_copy.copy(from_env, to_env, from_vpc, to_vpc, svc, template, no_maintenance_page)
|
|
132
|
+
except PlatformException as err:
|
|
133
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -4,14 +4,12 @@ from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VER
|
|
|
4
4
|
from dbt_platform_helper.domain.copilot_environment import CopilotEnvironment
|
|
5
5
|
from dbt_platform_helper.domain.maintenance_page import MaintenancePage
|
|
6
6
|
from dbt_platform_helper.domain.terraform_environment import TerraformEnvironment
|
|
7
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
7
8
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
8
9
|
from dbt_platform_helper.providers.cloudformation import CloudFormation
|
|
9
10
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
10
11
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
11
12
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
12
|
-
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
13
|
-
PlatformHelperVersioning,
|
|
14
|
-
)
|
|
15
13
|
from dbt_platform_helper.providers.vpc import VpcProvider
|
|
16
14
|
from dbt_platform_helper.utils.application import load_application
|
|
17
15
|
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
@@ -94,9 +92,10 @@ def generate(name):
|
|
|
94
92
|
help=f"Override the default version of terraform-platform-modules. (Default version is '{DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION}').",
|
|
95
93
|
)
|
|
96
94
|
def generate_terraform(name, terraform_platform_modules_version):
|
|
97
|
-
|
|
95
|
+
click_io = ClickIOProvider()
|
|
98
96
|
try:
|
|
99
|
-
|
|
97
|
+
session = get_aws_session_or_abort()
|
|
98
|
+
config_provider = ConfigProvider(ConfigValidator(session=session))
|
|
100
99
|
TerraformEnvironment(config_provider).generate(name, terraform_platform_modules_version)
|
|
101
100
|
except PlatformException as err:
|
|
102
|
-
|
|
101
|
+
click_io.abort_with_error(str(err))
|
|
@@ -3,7 +3,7 @@ import click
|
|
|
3
3
|
|
|
4
4
|
from dbt_platform_helper.commands.copilot import make_addons
|
|
5
5
|
from dbt_platform_helper.commands.pipeline import generate as pipeline_generate
|
|
6
|
-
from dbt_platform_helper.domain.versioning import
|
|
6
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
7
7
|
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
8
8
|
|
|
9
9
|
|
|
@@ -16,7 +16,6 @@ def generate(ctx: click.Context):
|
|
|
16
16
|
|
|
17
17
|
Wraps pipeline generate and make-addons.
|
|
18
18
|
"""
|
|
19
|
-
|
|
20
|
-
RequiredVersion().check_platform_helper_version_mismatch()
|
|
19
|
+
PlatformHelperVersioning().check_platform_helper_version_mismatch()
|
|
21
20
|
ctx.invoke(pipeline_generate)
|
|
22
21
|
ctx.invoke(make_addons)
|
|
@@ -2,9 +2,7 @@ import click
|
|
|
2
2
|
from slack_sdk import WebClient
|
|
3
3
|
from slack_sdk.models import blocks
|
|
4
4
|
|
|
5
|
-
from dbt_platform_helper.
|
|
6
|
-
PlatformHelperVersioning,
|
|
7
|
-
)
|
|
5
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
8
6
|
from dbt_platform_helper.utils.arn_parser import ARN
|
|
9
7
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
10
8
|
|
|
@@ -3,13 +3,11 @@ import click
|
|
|
3
3
|
|
|
4
4
|
from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
|
|
5
5
|
from dbt_platform_helper.domain.pipelines import Pipelines
|
|
6
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
6
7
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
7
8
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
8
9
|
from dbt_platform_helper.providers.ecr import ECRProvider
|
|
9
10
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
10
|
-
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
11
|
-
PlatformHelperVersioning,
|
|
12
|
-
)
|
|
13
11
|
from dbt_platform_helper.providers.terraform_manifest import TerraformManifestProvider
|
|
14
12
|
from dbt_platform_helper.utils.aws import get_codestar_connection_arn
|
|
15
13
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
@@ -6,9 +6,7 @@ import click
|
|
|
6
6
|
from botocore.exceptions import ClientError
|
|
7
7
|
from cloudfoundry_client.client import CloudFoundryClient
|
|
8
8
|
|
|
9
|
-
from dbt_platform_helper.
|
|
10
|
-
PlatformHelperVersioning,
|
|
11
|
-
)
|
|
9
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
12
10
|
from dbt_platform_helper.utils.application import get_application_name
|
|
13
11
|
from dbt_platform_helper.utils.aws import SSM_BASE_PATH
|
|
14
12
|
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from dbt_platform_helper.domain.versioning import
|
|
3
|
+
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
|
|
4
4
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
5
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
6
6
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
@@ -32,6 +32,6 @@ def get_platform_helper_for_project(pipeline):
|
|
|
32
32
|
- Fall back on the version in the deprecated '.platform-helper-version' file
|
|
33
33
|
"""
|
|
34
34
|
try:
|
|
35
|
-
|
|
35
|
+
PlatformHelperVersioning().get_required_version(pipeline)
|
|
36
36
|
except PlatformException as err:
|
|
37
37
|
ClickIOProvider().abort_with_error(str(err))
|