dbt-platform-helper 13.1.0__py3-none-any.whl → 13.1.2__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 +4 -4
- dbt_platform_helper/commands/codebase.py +4 -4
- dbt_platform_helper/commands/conduit.py +4 -4
- dbt_platform_helper/commands/config.py +7 -5
- dbt_platform_helper/commands/copilot.py +12 -391
- dbt_platform_helper/commands/environment.py +4 -4
- dbt_platform_helper/commands/generate.py +1 -1
- dbt_platform_helper/commands/notify.py +4 -4
- dbt_platform_helper/commands/pipeline.py +4 -4
- dbt_platform_helper/commands/secrets.py +4 -4
- dbt_platform_helper/commands/version.py +1 -1
- dbt_platform_helper/domain/codebase.py +4 -9
- dbt_platform_helper/domain/copilot.py +394 -0
- dbt_platform_helper/domain/copilot_environment.py +6 -6
- dbt_platform_helper/domain/maintenance_page.py +193 -424
- dbt_platform_helper/domain/versioning.py +67 -0
- dbt_platform_helper/providers/io.py +14 -0
- dbt_platform_helper/providers/load_balancers.py +258 -43
- dbt_platform_helper/providers/platform_config_schema.py +3 -1
- dbt_platform_helper/providers/platform_helper_versioning.py +107 -0
- dbt_platform_helper/providers/semantic_version.py +27 -7
- dbt_platform_helper/providers/version.py +24 -0
- dbt_platform_helper/utils/application.py +14 -0
- dbt_platform_helper/utils/files.py +6 -0
- dbt_platform_helper/utils/versioning.py +11 -158
- {dbt_platform_helper-13.1.0.dist-info → dbt_platform_helper-13.1.2.dist-info}/METADATA +3 -4
- {dbt_platform_helper-13.1.0.dist-info → dbt_platform_helper-13.1.2.dist-info}/RECORD +30 -27
- {dbt_platform_helper-13.1.0.dist-info → dbt_platform_helper-13.1.2.dist-info}/LICENSE +0 -0
- {dbt_platform_helper-13.1.0.dist-info → dbt_platform_helper-13.1.2.dist-info}/WHEEL +0 -0
- {dbt_platform_helper-13.1.0.dist-info → dbt_platform_helper-13.1.2.dist-info}/entry_points.txt +0 -0
|
@@ -10,11 +10,11 @@ from datetime import timedelta
|
|
|
10
10
|
import click
|
|
11
11
|
from prettytable import PrettyTable
|
|
12
12
|
|
|
13
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
14
|
+
PlatformHelperVersioning,
|
|
15
|
+
)
|
|
13
16
|
from dbt_platform_helper.utils.application import load_application
|
|
14
17
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
15
|
-
from dbt_platform_helper.utils.versioning import (
|
|
16
|
-
check_platform_helper_version_needs_update,
|
|
17
|
-
)
|
|
18
18
|
|
|
19
19
|
YELLOW = "\033[93m"
|
|
20
20
|
CYAN = "\033[96m"
|
|
@@ -97,7 +97,7 @@ def get_query_results(env, app, query_string, timeout):
|
|
|
97
97
|
@click.group(chain=True, cls=ClickDocOptGroup, deprecated=True)
|
|
98
98
|
def application():
|
|
99
99
|
"""[DEPRECATED] Application metrics."""
|
|
100
|
-
|
|
100
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
@application.command(deprecated=True)
|
|
@@ -3,16 +3,16 @@ import click
|
|
|
3
3
|
from dbt_platform_helper.domain.codebase import Codebase
|
|
4
4
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
5
5
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
6
|
-
from dbt_platform_helper.
|
|
7
|
-
|
|
8
|
-
check_platform_helper_version_needs_update,
|
|
6
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
7
|
+
PlatformHelperVersioning,
|
|
9
8
|
)
|
|
9
|
+
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
13
13
|
def codebase():
|
|
14
14
|
"""Codebase commands."""
|
|
15
|
-
|
|
15
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@codebase.command()
|
|
@@ -5,12 +5,12 @@ 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
7
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
8
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
9
|
+
PlatformHelperVersioning,
|
|
10
|
+
)
|
|
8
11
|
from dbt_platform_helper.providers.secrets import Secrets
|
|
9
12
|
from dbt_platform_helper.utils.application import load_application
|
|
10
13
|
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
11
|
-
from dbt_platform_helper.utils.versioning import (
|
|
12
|
-
check_platform_helper_version_needs_update,
|
|
13
|
-
)
|
|
14
14
|
|
|
15
15
|
CONDUIT_ACCESS_OPTIONS = ["read", "write", "admin"]
|
|
16
16
|
|
|
@@ -28,7 +28,7 @@ CONDUIT_ACCESS_OPTIONS = ["read", "write", "admin"]
|
|
|
28
28
|
def conduit(addon_name: str, app: str, env: str, access: str):
|
|
29
29
|
"""Opens a shell for a given addon_name create a conduit connection to
|
|
30
30
|
interact with postgres, opensearch or redis."""
|
|
31
|
-
|
|
31
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
32
32
|
application = load_application(app)
|
|
33
33
|
|
|
34
34
|
try:
|
|
@@ -9,13 +9,14 @@ import click
|
|
|
9
9
|
from prettytable import PrettyTable
|
|
10
10
|
|
|
11
11
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
12
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
12
13
|
from dbt_platform_helper.providers.semantic_version import (
|
|
13
14
|
IncompatibleMajorVersionException,
|
|
14
15
|
)
|
|
15
16
|
from dbt_platform_helper.providers.validation import ValidationException
|
|
16
17
|
from dbt_platform_helper.utils import versioning
|
|
17
18
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
18
|
-
from dbt_platform_helper.utils.versioning import
|
|
19
|
+
from dbt_platform_helper.utils.versioning import get_platform_helper_version_status
|
|
19
20
|
|
|
20
21
|
yes = "\033[92m✔\033[0m"
|
|
21
22
|
no = "\033[91m✖\033[0m"
|
|
@@ -75,14 +76,15 @@ def deployment():
|
|
|
75
76
|
click.secho()
|
|
76
77
|
|
|
77
78
|
compatible = True
|
|
78
|
-
|
|
79
|
+
platform_helper_version_status = get_platform_helper_version_status()
|
|
80
|
+
ClickIOProvider().process_messages(platform_helper_version_status.validate())
|
|
79
81
|
copilot_versions = versioning.get_copilot_versions()
|
|
80
82
|
aws_versions = versioning.get_aws_versions()
|
|
81
|
-
_check_tool_versions(
|
|
83
|
+
_check_tool_versions(platform_helper_version_status, copilot_versions, aws_versions)
|
|
82
84
|
click.secho("Checking addons templates versions...", fg="blue")
|
|
83
85
|
|
|
84
|
-
local_version =
|
|
85
|
-
latest_release =
|
|
86
|
+
local_version = platform_helper_version_status.local
|
|
87
|
+
latest_release = platform_helper_version_status.latest
|
|
86
88
|
addons_templates_table = PrettyTable()
|
|
87
89
|
addons_templates_table.field_names = [
|
|
88
90
|
"Addons Template File",
|
|
@@ -1,248 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
|
-
import copy
|
|
4
|
-
import json
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from pathlib import PosixPath
|
|
7
|
-
|
|
8
3
|
import click
|
|
9
|
-
import yaml
|
|
10
|
-
from schema import SchemaError
|
|
11
4
|
|
|
12
|
-
from dbt_platform_helper.
|
|
5
|
+
from dbt_platform_helper.domain.copilot import Copilot
|
|
13
6
|
from dbt_platform_helper.domain.copilot_environment import CopilotTemplating
|
|
14
7
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
15
8
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
16
9
|
from dbt_platform_helper.providers.files import FileProvider
|
|
17
|
-
from dbt_platform_helper.
|
|
18
|
-
from dbt_platform_helper.
|
|
19
|
-
|
|
20
|
-
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
21
|
-
from dbt_platform_helper.utils.files import generate_override_files
|
|
22
|
-
from dbt_platform_helper.utils.messages import abort_with_error
|
|
23
|
-
from dbt_platform_helper.utils.template import ADDON_TEMPLATE_MAP
|
|
24
|
-
from dbt_platform_helper.utils.template import camel_case
|
|
25
|
-
from dbt_platform_helper.utils.template import setup_templates
|
|
26
|
-
from dbt_platform_helper.utils.validation import validate_addons
|
|
27
|
-
from dbt_platform_helper.utils.versioning import (
|
|
28
|
-
check_platform_helper_version_needs_update,
|
|
10
|
+
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
11
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
12
|
+
PlatformHelperVersioning,
|
|
29
13
|
)
|
|
14
|
+
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
SERVICE_TYPES = [
|
|
36
|
-
"Load Balanced Web Service",
|
|
37
|
-
"Backend Service",
|
|
38
|
-
"Request-Driven Web Service",
|
|
39
|
-
"Static Site",
|
|
40
|
-
"Worker Service",
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def list_copilot_local_environments():
|
|
45
|
-
return [
|
|
46
|
-
path.parent.parts[-1] for path in Path("./copilot/environments/").glob("*/manifest.yml")
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def is_service(path: PosixPath) -> bool:
|
|
51
|
-
with open(path) as manifest_file:
|
|
52
|
-
data = yaml.safe_load(manifest_file)
|
|
53
|
-
if not data or not data.get("type"):
|
|
54
|
-
click.echo(
|
|
55
|
-
click.style(f"No type defined in manifest file {str(path)}; exiting", fg="red")
|
|
56
|
-
)
|
|
57
|
-
exit(1)
|
|
58
|
-
|
|
59
|
-
return data.get("type") in SERVICE_TYPES
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def list_copilot_local_services():
|
|
63
|
-
return [
|
|
64
|
-
path.parent.parts[-1]
|
|
65
|
-
for path in Path("./copilot/").glob("*/manifest.yml")
|
|
66
|
-
if is_service(path)
|
|
67
|
-
]
|
|
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.
|
|
68
19
|
|
|
69
20
|
|
|
70
21
|
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
71
22
|
def copilot():
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _validate_and_normalise_extensions_config(config_file, key_in_config_file=None):
|
|
76
|
-
"""Load a config file, validate it against the extensions schemas and return
|
|
77
|
-
the normalised config dict."""
|
|
78
|
-
|
|
79
|
-
def _lookup_plan(addon_type, env_conf):
|
|
80
|
-
plan = env_conf.pop("plan", None)
|
|
81
|
-
conf = addon_plans[addon_type][plan] if plan else {}
|
|
82
|
-
|
|
83
|
-
# Make a copy of the addon plan config so subsequent
|
|
84
|
-
# calls do not override the root object
|
|
85
|
-
conf = conf.copy()
|
|
86
|
-
|
|
87
|
-
conf.update(env_conf)
|
|
88
|
-
|
|
89
|
-
return conf
|
|
90
|
-
|
|
91
|
-
def _normalise_keys(source: dict):
|
|
92
|
-
return {k.replace("-", "_"): v for k, v in source.items()}
|
|
93
|
-
|
|
94
|
-
with open(PACKAGE_DIR / "addon-plans.yml", "r") as fd:
|
|
95
|
-
addon_plans = yaml.safe_load(fd)
|
|
96
|
-
|
|
97
|
-
# load and validate config
|
|
98
|
-
with open(config_file, "r") as fd:
|
|
99
|
-
config = yaml.safe_load(fd)
|
|
100
|
-
|
|
101
|
-
if config and key_in_config_file:
|
|
102
|
-
config = config[key_in_config_file]
|
|
103
|
-
|
|
104
|
-
# empty file
|
|
105
|
-
if not config:
|
|
106
|
-
return {}
|
|
107
|
-
|
|
108
|
-
errors = validate_addons(config)
|
|
109
|
-
|
|
110
|
-
if errors:
|
|
111
|
-
click.echo(click.style(f"Errors found in {config_file}:", fg="red"))
|
|
112
|
-
for addon, error in errors.items():
|
|
113
|
-
click.echo(click.style(f"Addon '{addon}': {error}", fg="red"))
|
|
114
|
-
exit(1)
|
|
115
|
-
|
|
116
|
-
env_names = list_copilot_local_environments()
|
|
117
|
-
svc_names = list_copilot_local_services()
|
|
118
|
-
|
|
119
|
-
if not env_names:
|
|
120
|
-
click.echo(
|
|
121
|
-
click.style(f"No environments found in ./copilot/environments; exiting", fg="red")
|
|
122
|
-
)
|
|
123
|
-
exit(1)
|
|
124
|
-
|
|
125
|
-
if not svc_names:
|
|
126
|
-
click.echo(click.style(f"No services found in ./copilot/; exiting", fg="red"))
|
|
127
|
-
exit(1)
|
|
128
|
-
|
|
129
|
-
normalised_config = {}
|
|
130
|
-
config_has_errors = False
|
|
131
|
-
for addon_name, addon_config in config.items():
|
|
132
|
-
addon_type = addon_config["type"]
|
|
133
|
-
normalised_config[addon_name] = copy.deepcopy(addon_config)
|
|
134
|
-
|
|
135
|
-
if "services" in normalised_config[addon_name]:
|
|
136
|
-
if normalised_config[addon_name]["services"] == "__all__":
|
|
137
|
-
normalised_config[addon_name]["services"] = svc_names
|
|
138
|
-
|
|
139
|
-
if not set(normalised_config[addon_name]["services"]).issubset(set(svc_names)):
|
|
140
|
-
click.echo(
|
|
141
|
-
click.style(
|
|
142
|
-
f"Services listed in {addon_name}.services do not exist in ./copilot/",
|
|
143
|
-
fg="red",
|
|
144
|
-
),
|
|
145
|
-
)
|
|
146
|
-
config_has_errors = True
|
|
147
|
-
|
|
148
|
-
environments = normalised_config[addon_name].pop("environments", {})
|
|
149
|
-
default = environments.pop("*", environments.pop("default", {}))
|
|
150
|
-
|
|
151
|
-
initial = _lookup_plan(addon_type, default)
|
|
152
|
-
|
|
153
|
-
missing_envs = set(environments.keys()) - set(env_names)
|
|
154
|
-
if missing_envs:
|
|
155
|
-
click.echo(
|
|
156
|
-
click.style(
|
|
157
|
-
f"Environment keys listed in {addon_name} do not match those defined in ./copilot/environments.",
|
|
158
|
-
fg="red",
|
|
159
|
-
)
|
|
160
|
-
),
|
|
161
|
-
click.echo(
|
|
162
|
-
click.style(
|
|
163
|
-
f" Missing environments: {', '.join(sorted(missing_envs))}",
|
|
164
|
-
fg="white",
|
|
165
|
-
),
|
|
166
|
-
)
|
|
167
|
-
config_has_errors = True
|
|
168
|
-
|
|
169
|
-
if config_has_errors:
|
|
170
|
-
continue
|
|
171
|
-
|
|
172
|
-
normalised_environments = {}
|
|
173
|
-
|
|
174
|
-
for env in env_names:
|
|
175
|
-
normalised_environments[env] = _normalise_keys(initial)
|
|
176
|
-
|
|
177
|
-
for env_name, env_config in environments.items():
|
|
178
|
-
if env_config is None:
|
|
179
|
-
env_config = {}
|
|
180
|
-
normalised_environments[env_name].update(
|
|
181
|
-
_lookup_plan(addon_type, _normalise_keys(env_config))
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
normalised_config[addon_name]["environments"] = normalised_environments
|
|
185
|
-
|
|
186
|
-
if config_has_errors:
|
|
187
|
-
exit(1)
|
|
188
|
-
|
|
189
|
-
return normalised_config
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def get_log_destination_arn():
|
|
193
|
-
"""Get destination arns stored in param store in projects aws account."""
|
|
194
|
-
session = get_aws_session_or_abort()
|
|
195
|
-
client = session.client("ssm", region_name="eu-west-2")
|
|
196
|
-
response = client.get_parameters(Names=["/copilot/tools/central_log_groups"])
|
|
197
|
-
|
|
198
|
-
if not response["Parameters"]:
|
|
199
|
-
click.echo(
|
|
200
|
-
click.style(
|
|
201
|
-
"No aws central log group defined in Parameter Store at location /copilot/tools/central_log_groups; exiting",
|
|
202
|
-
fg="red",
|
|
203
|
-
)
|
|
204
|
-
)
|
|
205
|
-
exit(1)
|
|
206
|
-
|
|
207
|
-
destination_arns = json.loads(response["Parameters"][0]["Value"])
|
|
208
|
-
return destination_arns
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def _generate_svc_overrides(base_path, templates, name):
|
|
212
|
-
click.echo(f"\n>>> Generating service overrides for {name}\n")
|
|
213
|
-
overrides_path = base_path.joinpath(f"copilot/{name}/overrides")
|
|
214
|
-
overrides_path.mkdir(parents=True, exist_ok=True)
|
|
215
|
-
overrides_file = overrides_path.joinpath("cfn.patches.yml")
|
|
216
|
-
overrides_file.write_text(templates.get_template("svc/overrides/cfn.patches.yml").render())
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
def _get_s3_kms_alias_arns(session, application_name, config):
|
|
220
|
-
application = load_application(application_name, session)
|
|
221
|
-
arns = {}
|
|
222
|
-
|
|
223
|
-
for environment_name in application.environments:
|
|
224
|
-
if environment_name not in config:
|
|
225
|
-
continue
|
|
226
|
-
|
|
227
|
-
if "bucket_name" not in config[environment_name]:
|
|
228
|
-
continue
|
|
229
|
-
|
|
230
|
-
bucket_name = config[environment_name]["bucket_name"]
|
|
231
|
-
kms_client = application.environments[environment_name].session.client("kms")
|
|
232
|
-
alias_name = f"alias/{application_name}-{environment_name}-{bucket_name}-key"
|
|
233
|
-
|
|
234
|
-
try:
|
|
235
|
-
response = kms_client.describe_key(KeyId=alias_name)
|
|
236
|
-
except kms_client.exceptions.NotFoundException:
|
|
237
|
-
pass
|
|
238
|
-
else:
|
|
239
|
-
arns[environment_name] = response["KeyMetadata"]["Arn"]
|
|
240
|
-
|
|
241
|
-
return arns
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
def copilot_provider():
|
|
245
|
-
return CopilotTemplating()
|
|
23
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
246
24
|
|
|
247
25
|
|
|
248
26
|
@copilot.command()
|
|
@@ -250,163 +28,6 @@ def make_addons():
|
|
|
250
28
|
"""Generate addons CloudFormation for each environment."""
|
|
251
29
|
try:
|
|
252
30
|
config_provider = ConfigProvider(ConfigValidator())
|
|
253
|
-
|
|
254
|
-
except Exception as
|
|
255
|
-
abort_with_error(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
def _make_addons(config_provider: ConfigProvider):
|
|
259
|
-
config_provider.config_file_check()
|
|
260
|
-
try:
|
|
261
|
-
config = config_provider.load_and_validate_platform_config()
|
|
262
|
-
except SchemaError as ex:
|
|
263
|
-
click.secho(f"Invalid `{PLATFORM_CONFIG_FILE}` file: {str(ex)}", fg="red")
|
|
264
|
-
raise click.Abort
|
|
265
|
-
|
|
266
|
-
templates = setup_templates()
|
|
267
|
-
extensions = _get_extensions()
|
|
268
|
-
session = get_aws_session_or_abort()
|
|
269
|
-
|
|
270
|
-
application_name = get_application_name()
|
|
271
|
-
|
|
272
|
-
click.echo("\n>>> Generating Terraform compatible addons CloudFormation\n")
|
|
273
|
-
|
|
274
|
-
output_dir = Path(".").absolute()
|
|
275
|
-
env_path = Path(f"copilot/environments/")
|
|
276
|
-
env_addons_path = env_path / "addons"
|
|
277
|
-
env_overrides_path = env_path / "overrides"
|
|
278
|
-
|
|
279
|
-
_cleanup_old_files(extensions, output_dir, env_addons_path, env_overrides_path)
|
|
280
|
-
_generate_env_overrides(output_dir)
|
|
281
|
-
|
|
282
|
-
svc_names = list_copilot_local_services()
|
|
283
|
-
base_path = Path(".")
|
|
284
|
-
for svc_name in svc_names:
|
|
285
|
-
_generate_svc_overrides(base_path, templates, svc_name)
|
|
286
|
-
|
|
287
|
-
services = []
|
|
288
|
-
for ext_name, ext_data in extensions.items():
|
|
289
|
-
extension = {**ext_data}
|
|
290
|
-
addon_type = extension.pop("type")
|
|
291
|
-
environments = extension.pop("environments")
|
|
292
|
-
environment_addon_config = {
|
|
293
|
-
"addon_type": addon_type,
|
|
294
|
-
"environments": environments,
|
|
295
|
-
"name": extension.get("name", None) or ext_name,
|
|
296
|
-
"prefix": camel_case(ext_name),
|
|
297
|
-
"secret_name": ext_name.upper().replace("-", "_"),
|
|
298
|
-
**extension,
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
services.append(environment_addon_config)
|
|
302
|
-
|
|
303
|
-
service_addon_config = {
|
|
304
|
-
"application_name": application_name,
|
|
305
|
-
"name": extension.get("name", None) or ext_name,
|
|
306
|
-
"prefix": camel_case(ext_name),
|
|
307
|
-
"environments": environments,
|
|
308
|
-
**extension,
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
log_destination_arns = get_log_destination_arn()
|
|
312
|
-
|
|
313
|
-
if addon_type in ["s3", "s3-policy"]:
|
|
314
|
-
if extensions[ext_name].get("serve_static_content"):
|
|
315
|
-
continue
|
|
316
|
-
|
|
317
|
-
s3_kms_arns = _get_s3_kms_alias_arns(session, application_name, environments)
|
|
318
|
-
for environment_name in environments:
|
|
319
|
-
environments[environment_name]["kms_key_arn"] = s3_kms_arns.get(
|
|
320
|
-
environment_name, "kms-key-not-found"
|
|
321
|
-
)
|
|
322
|
-
|
|
323
|
-
_generate_service_addons(
|
|
324
|
-
extension,
|
|
325
|
-
ext_name,
|
|
326
|
-
addon_type,
|
|
327
|
-
output_dir,
|
|
328
|
-
service_addon_config,
|
|
329
|
-
templates,
|
|
330
|
-
log_destination_arns,
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
environments = config_provider.apply_environment_defaults(config)["environments"]
|
|
334
|
-
|
|
335
|
-
provider = copilot_provider()
|
|
336
|
-
provider.generate_cross_account_s3_policies(environments, extensions)
|
|
337
|
-
|
|
338
|
-
click.echo(templates.get_template("addon-instructions.txt").render(services=services))
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
def _get_extensions():
|
|
342
|
-
config = _validate_and_normalise_extensions_config(PACKAGE_DIR / "default-extensions.yml")
|
|
343
|
-
project_config = _validate_and_normalise_extensions_config(PLATFORM_CONFIG_FILE, "extensions")
|
|
344
|
-
config.update(project_config)
|
|
345
|
-
return config
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
def _generate_env_overrides(output_dir):
|
|
349
|
-
path = "templates/env/terraform-overrides"
|
|
350
|
-
click.echo("\n>>> Generating Environment overrides\n")
|
|
351
|
-
overrides_path = output_dir.joinpath(f"copilot/environments/overrides")
|
|
352
|
-
overrides_path.mkdir(parents=True, exist_ok=True)
|
|
353
|
-
template_overrides_path = Path(__file__).parent.parent.joinpath(path)
|
|
354
|
-
generate_override_files(Path("."), template_overrides_path, overrides_path)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
def _generate_service_addons(
|
|
358
|
-
addon_config,
|
|
359
|
-
addon_name,
|
|
360
|
-
addon_type,
|
|
361
|
-
output_dir,
|
|
362
|
-
service_addon_config,
|
|
363
|
-
templates,
|
|
364
|
-
log_destination_arns,
|
|
365
|
-
):
|
|
366
|
-
# generate svc addons
|
|
367
|
-
for addon_template in ADDON_TEMPLATE_MAP.get(addon_type, []):
|
|
368
|
-
template = templates.get_template(addon_template)
|
|
369
|
-
|
|
370
|
-
for svc in addon_config.get("services", []):
|
|
371
|
-
service_path = Path(f"copilot/{svc}/addons/")
|
|
372
|
-
|
|
373
|
-
contents = template.render(
|
|
374
|
-
{
|
|
375
|
-
"addon_config": service_addon_config,
|
|
376
|
-
"log_destination": log_destination_arns,
|
|
377
|
-
}
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
(output_dir / service_path).mkdir(parents=True, exist_ok=True)
|
|
381
|
-
click.echo(
|
|
382
|
-
FileProvider.mkfile(
|
|
383
|
-
output_dir, service_path / f"{addon_name}.yml", contents, overwrite=True
|
|
384
|
-
)
|
|
385
|
-
)
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
def _cleanup_old_files(config, output_dir, env_addons_path, env_overrides_path):
|
|
389
|
-
def _rmdir(path):
|
|
390
|
-
if not path.exists():
|
|
391
|
-
return
|
|
392
|
-
for f in path.iterdir():
|
|
393
|
-
if f.is_file():
|
|
394
|
-
f.unlink()
|
|
395
|
-
if f.is_dir():
|
|
396
|
-
_rmdir(f)
|
|
397
|
-
f.rmdir()
|
|
398
|
-
|
|
399
|
-
_rmdir(output_dir / env_addons_path)
|
|
400
|
-
_rmdir(output_dir / env_overrides_path)
|
|
401
|
-
|
|
402
|
-
all_services = set()
|
|
403
|
-
for services in [v["services"] for v in config.values() if "services" in v]:
|
|
404
|
-
all_services.update(services)
|
|
405
|
-
|
|
406
|
-
for service in all_services:
|
|
407
|
-
svc_addons_dir = Path(output_dir, "copilot", service, "addons")
|
|
408
|
-
if not svc_addons_dir.exists():
|
|
409
|
-
continue
|
|
410
|
-
for f in svc_addons_dir.iterdir():
|
|
411
|
-
if f.is_file():
|
|
412
|
-
f.unlink()
|
|
31
|
+
Copilot(config_provider, FileProvider(), CopilotTemplating()).make_addons()
|
|
32
|
+
except Exception as err:
|
|
33
|
+
ClickIOProvider().abort_with_error(str(err))
|
|
@@ -9,13 +9,13 @@ from dbt_platform_helper.providers.cloudformation import CloudFormation
|
|
|
9
9
|
from dbt_platform_helper.providers.config import ConfigProvider
|
|
10
10
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
11
11
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
12
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
13
|
+
PlatformHelperVersioning,
|
|
14
|
+
)
|
|
12
15
|
from dbt_platform_helper.providers.vpc import VpcProvider
|
|
13
16
|
from dbt_platform_helper.utils.application import load_application
|
|
14
17
|
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
15
18
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
16
|
-
from dbt_platform_helper.utils.versioning import (
|
|
17
|
-
check_platform_helper_version_needs_update,
|
|
18
|
-
)
|
|
19
19
|
|
|
20
20
|
AVAILABLE_TEMPLATES = ["default", "migration", "dmas-migration"]
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ AVAILABLE_TEMPLATES = ["default", "migration", "dmas-migration"]
|
|
|
23
23
|
@click.group(cls=ClickDocOptGroup)
|
|
24
24
|
def environment():
|
|
25
25
|
"""Commands affecting environments."""
|
|
26
|
-
|
|
26
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@environment.command()
|
|
@@ -3,8 +3,8 @@ 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 RequiredVersion
|
|
6
7
|
from dbt_platform_helper.utils.click import ClickDocOptCommand
|
|
7
|
-
from dbt_platform_helper.utils.versioning import RequiredVersion
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
@click.command(cls=ClickDocOptCommand)
|
|
@@ -2,16 +2,16 @@ import click
|
|
|
2
2
|
from slack_sdk import WebClient
|
|
3
3
|
from slack_sdk.models import blocks
|
|
4
4
|
|
|
5
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
6
|
+
PlatformHelperVersioning,
|
|
7
|
+
)
|
|
5
8
|
from dbt_platform_helper.utils.arn_parser import ARN
|
|
6
9
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
7
|
-
from dbt_platform_helper.utils.versioning import (
|
|
8
|
-
check_platform_helper_version_needs_update,
|
|
9
|
-
)
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.group(cls=ClickDocOptGroup, help="Send Slack notifications")
|
|
13
13
|
def notify():
|
|
14
|
-
|
|
14
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@notify.command(
|
|
@@ -7,19 +7,19 @@ from dbt_platform_helper.providers.config import ConfigProvider
|
|
|
7
7
|
from dbt_platform_helper.providers.config_validator import ConfigValidator
|
|
8
8
|
from dbt_platform_helper.providers.ecr import ECRProvider
|
|
9
9
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
10
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
11
|
+
PlatformHelperVersioning,
|
|
12
|
+
)
|
|
10
13
|
from dbt_platform_helper.providers.terraform_manifest import TerraformManifestProvider
|
|
11
14
|
from dbt_platform_helper.utils.aws import get_codestar_connection_arn
|
|
12
15
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
13
16
|
from dbt_platform_helper.utils.git import git_remote
|
|
14
|
-
from dbt_platform_helper.utils.versioning import (
|
|
15
|
-
check_platform_helper_version_needs_update,
|
|
16
|
-
)
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
20
20
|
def pipeline():
|
|
21
21
|
"""Pipeline commands."""
|
|
22
|
-
|
|
22
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
@pipeline.command()
|
|
@@ -6,15 +6,15 @@ import click
|
|
|
6
6
|
from botocore.exceptions import ClientError
|
|
7
7
|
from cloudfoundry_client.client import CloudFoundryClient
|
|
8
8
|
|
|
9
|
+
from dbt_platform_helper.providers.platform_helper_versioning import (
|
|
10
|
+
PlatformHelperVersioning,
|
|
11
|
+
)
|
|
9
12
|
from dbt_platform_helper.utils.application import get_application_name
|
|
10
13
|
from dbt_platform_helper.utils.aws import SSM_BASE_PATH
|
|
11
14
|
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
12
15
|
from dbt_platform_helper.utils.aws import get_ssm_secrets
|
|
13
16
|
from dbt_platform_helper.utils.aws import set_ssm_param
|
|
14
17
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
15
|
-
from dbt_platform_helper.utils.versioning import (
|
|
16
|
-
check_platform_helper_version_needs_update,
|
|
17
|
-
)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def secret_should_be_skipped(secret_name):
|
|
@@ -42,7 +42,7 @@ def get_paas_env_vars(client: CloudFoundryClient, paas: str) -> dict:
|
|
|
42
42
|
|
|
43
43
|
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
44
44
|
def secrets():
|
|
45
|
-
|
|
45
|
+
PlatformHelperVersioning().check_if_needs_update()
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
@secrets.command()
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
+
from dbt_platform_helper.domain.versioning import RequiredVersion
|
|
3
4
|
from dbt_platform_helper.platform_exception import PlatformException
|
|
4
5
|
from dbt_platform_helper.providers.io import ClickIOProvider
|
|
5
6
|
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
6
|
-
from dbt_platform_helper.utils.versioning import RequiredVersion
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@click.group(chain=True, cls=ClickDocOptGroup)
|