dbt-platform-helper 10.9.0__py3-none-any.whl → 10.10.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.

@@ -222,6 +222,9 @@ def _get_s3_kms_alias_arns(session, application_name, config):
222
222
  if environment_name not in config:
223
223
  continue
224
224
 
225
+ if "bucket_name" not in config[environment_name]:
226
+ continue
227
+
225
228
  bucket_name = config[environment_name]["bucket_name"]
226
229
  kms_client = application.environments[environment_name].session.client("kms")
227
230
  alias_name = f"alias/{application_name}-{environment_name}-{bucket_name}-key"
@@ -313,6 +316,8 @@ def make_addons():
313
316
  log_destination_arns = get_log_destination_arn()
314
317
 
315
318
  if addon_type in ["s3", "s3-policy"]:
319
+ if config[addon_name].get("serve_static_content"):
320
+ continue
316
321
  if is_terraform:
317
322
  s3_kms_arns = _get_s3_kms_alias_arns(session, application_name, environments)
318
323
  for environment_name in environments:
@@ -238,15 +238,16 @@ def get_subnet_ids(session, vpc_id):
238
238
  return public, private
239
239
 
240
240
 
241
- def get_cert_arn(session, env_name):
242
- certs = session.client("acm").list_certificates()["CertificateSummaryList"]
243
-
244
- for cert in certs:
245
- if env_name in cert["DomainName"]:
246
- return cert["CertificateArn"]
241
+ def get_cert_arn(session, application, env_name):
242
+ try:
243
+ arn = find_https_certificate(session, application, env_name)
244
+ except:
245
+ click.secho(
246
+ f"No certificate found with domain name matching environment {env_name}.", fg="red"
247
+ )
248
+ raise click.Abort
247
249
 
248
- click.secho(f"No certificate found with domain name matching environment {env_name}.", fg="red")
249
- raise click.Abort
250
+ return arn
250
251
 
251
252
 
252
253
  def get_env_ips(vpc: str, application_environment: Environment):
@@ -284,7 +285,7 @@ def generate(name, vpc_name):
284
285
 
285
286
  env_config = apply_environment_defaults(conf)["environments"][name]
286
287
 
287
- _generate_copilot_environment_manifests(name, env_config, session)
288
+ _generate_copilot_environment_manifests(name, conf["application"], env_config, session)
288
289
 
289
290
 
290
291
  @environment.command(help="Generate terraform manifest for the specified environment.")
@@ -308,12 +309,12 @@ def generate_terraform(name, terraform_platform_modules_version):
308
309
  )
309
310
 
310
311
 
311
- def _generate_copilot_environment_manifests(name, env_config, session):
312
+ def _generate_copilot_environment_manifests(name, application, env_config, session):
312
313
  env_template = setup_templates().get_template("env/manifest.yml")
313
314
  vpc_name = env_config.get("vpc", None)
314
315
  vpc_id = get_vpc_id(session, name, vpc_name)
315
316
  pub_subnet_ids, priv_subnet_ids = get_subnet_ids(session, vpc_id)
316
- cert_arn = get_cert_arn(session, name)
317
+ cert_arn = get_cert_arn(session, application, name)
317
318
  contents = env_template.render(
318
319
  {
319
320
  "name": name,
@@ -398,6 +399,23 @@ def find_https_listener(session: boto3.Session, app: str, env: str) -> str:
398
399
  return listener_arn
399
400
 
400
401
 
402
+ def find_https_certificate(session: boto3.Session, app: str, env: str) -> str:
403
+ listener_arn = find_https_listener(session, app, env)
404
+ cert_client = session.client("elbv2")
405
+ certificates = cert_client.describe_listener_certificates(ListenerArn=listener_arn)[
406
+ "Certificates"
407
+ ]
408
+
409
+ certificate_arn = None
410
+
411
+ try:
412
+ certificate_arn = next(c["CertificateArn"] for c in certificates if c["IsDefault"])
413
+ except StopIteration:
414
+ raise CertificateNotFoundError()
415
+
416
+ return certificate_arn
417
+
418
+
401
419
  def find_target_group(app: str, env: str, svc: str, session: boto3.Session) -> str:
402
420
  rg_tagging_client = session.client("resourcegroupstaggingapi")
403
421
  response = rg_tagging_client.get_resources(
@@ -650,6 +668,10 @@ def get_maintenance_page_template(template) -> str:
650
668
  return re.sub(r"[^\S]\s+", "", template_contents)
651
669
 
652
670
 
671
+ class CertificateNotFoundError(Exception):
672
+ pass
673
+
674
+
653
675
  class LoadBalancerNotFoundError(Exception):
654
676
  pass
655
677
 
@@ -72,10 +72,12 @@ def handler(event, context):
72
72
  Key=properties["S3ObjectKey"],
73
73
  )
74
74
  else:
75
+ content_type = properties.get("S3ObjectContentType", "binary/octet-stream")
75
76
  s3_client.put_object(
76
77
  Bucket=properties["S3Bucket"],
77
78
  Key=properties["S3ObjectKey"],
78
79
  Body=properties["S3ObjectBody"].encode("utf-8"),
80
+ ContentType=content_type,
79
81
  )
80
82
 
81
83
  send_response(event, context, "SUCCESS", f"{request_type}d")
@@ -201,6 +201,9 @@ Resources:
201
201
  S3Bucket: !Ref {{ addon_config.prefix }}Bucket
202
202
  S3ObjectKey: {{ s3object.key }}
203
203
  S3ObjectBody: {{ s3object.body }}
204
+ {% if s3object.content_type %}
205
+ S3ObjectContentType: {{ s3object.content_type }}
206
+ {% endif %}
204
207
  {% endfor %}
205
208
  {% endif %}
206
209
 
@@ -308,6 +308,7 @@ DATA_MIGRATION = {
308
308
 
309
309
  S3_BASE = {
310
310
  Optional("readonly"): bool,
311
+ Optional("serve_static_content"): bool,
311
312
  Optional("services"): Or("__all__", [str]),
312
313
  Optional("environments"): {
313
314
  ENV_NAME: {
@@ -328,12 +329,7 @@ S3_DEFINITION = dict(S3_BASE)
328
329
  S3_DEFINITION.update(
329
330
  {
330
331
  "type": "s3",
331
- Optional("objects"): [
332
- {
333
- "key": str,
334
- Optional("body"): str,
335
- }
336
- ],
332
+ Optional("objects"): [{"key": str, Optional("body"): str, Optional("content_type"): str}],
337
333
  }
338
334
  )
339
335
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-platform-helper
3
- Version: 10.9.0
3
+ Version: 10.10.0
4
4
  Summary: Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot.
5
5
  License: MIT
6
6
  Author: Department for Business and Trade Platform Team
@@ -9,10 +9,10 @@ dbt_platform_helper/commands/check_cloudformation.py,sha256=aLif3yMHKuZO0uvdUjTH
9
9
  dbt_platform_helper/commands/codebase.py,sha256=NchJzH-yxv5mXCe2rPyXVNHmXGEvjFUv0KhMKYsLNNQ,11380
10
10
  dbt_platform_helper/commands/conduit.py,sha256=M_-Lrcph4c4PFivfEzDEL2_PW_OzZaOtZXpgo_Ao3DU,14882
11
11
  dbt_platform_helper/commands/config.py,sha256=NOHea7OAjrl6XHlW6HMLn0m0T5lFPyNH3HXoyCOWsJk,12070
12
- dbt_platform_helper/commands/copilot.py,sha256=hGaF3631BCx9SKyY7BB-xK0B9cENK9UKffGiDO2Cp0Q,16556
12
+ dbt_platform_helper/commands/copilot.py,sha256=euid0FTlVtwKmBQ6vxt_HxtBdRYiVQvb-9CyrK1-MWc,16724
13
13
  dbt_platform_helper/commands/database.py,sha256=-DacXZ2LhwV3CRukG35urEU2TuNVZHppUA3EhbBNjUs,4840
14
14
  dbt_platform_helper/commands/dns.py,sha256=o7PkvHktZo0jmqbx0krJTL0R4GtWSf1rF2KDEWor8Ts,35211
15
- dbt_platform_helper/commands/environment.py,sha256=u4yl2fZa2XnzA5o8gk1x0_YfPqLCJAraaU6YU74mSxo,22563
15
+ dbt_platform_helper/commands/environment.py,sha256=MJcqYBGxMl3oZIJqnbUNNBbwi5WCShLujMUFgGlmzy8,23147
16
16
  dbt_platform_helper/commands/generate.py,sha256=YLCPb-xcPapGcsLn-7d1Am7BpGp5l0iecIDTOdNGjHk,722
17
17
  dbt_platform_helper/commands/notify.py,sha256=kVJ0s78QMiaEWPVKu_bbMko4DW2uJy2fu8-HNJsglyk,3748
18
18
  dbt_platform_helper/commands/pipeline.py,sha256=jQGwCRpJ_hXK988XmLHzRBHDWmhFzZb37wa75KuSd0M,5945
@@ -20,7 +20,7 @@ dbt_platform_helper/commands/secrets.py,sha256=2NtV5FGx-ErkMg2QMiDvFOp03cKVbLzgm
20
20
  dbt_platform_helper/commands/version.py,sha256=2r6c3-PSMMY_VAU32UNaPJJXOsouX1MQDWXnx3ZpGJI,1474
21
21
  dbt_platform_helper/constants.py,sha256=fzN2VZt81mspNfdYpNef5_eEjDVsh8GUYmhBMTIfPvI,232
22
22
  dbt_platform_helper/custom_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- dbt_platform_helper/custom_resources/s3_object.py,sha256=wJftyeHWUO2egObsNeQpStYI96e-vAJWJh6pq2CxV24,2396
23
+ dbt_platform_helper/custom_resources/s3_object.py,sha256=0mhLuKD0-vwuN1qmnLCrLo2qL58FvtCjNNjH34kac6Y,2526
24
24
  dbt_platform_helper/default-extensions.yml,sha256=SU1ZitskbuEBpvE7efc3s56eAUF11j70brhj_XrNMMo,493
25
25
  dbt_platform_helper/exceptions.py,sha256=BeqhBQHXS57ROwEEGCnd9qcMDbuKvsdeiYRUuTlhe4w,499
26
26
  dbt_platform_helper/jinja2_tags.py,sha256=jFyN_Sxmko1GSfvrqRIGQ80CCW8EwlCV3su0ahJPfoE,541
@@ -39,7 +39,7 @@ dbt_platform_helper/templates/addons/env/monitoring.yml,sha256=ZjvKhrhg6hIoQ51n0
39
39
  dbt_platform_helper/templates/addons/env/opensearch.yml,sha256=Ay0IAE8AWMEUjBRpMWyI4qLFmdwNkQwAN1ciTnuKb5c,10874
40
40
  dbt_platform_helper/templates/addons/env/rds-postgres.yml,sha256=uz7I9u8c-25ergwzNe1EQTT9TadlekeRyhgdpyNbCOo,25645
41
41
  dbt_platform_helper/templates/addons/env/redis-cluster.yml,sha256=dx6dYniLdhcX-hnSF6RKaO5ZWewAOYqHgX_MMhPkcjs,7634
42
- dbt_platform_helper/templates/addons/env/s3.yml,sha256=rnbmYKWi-SKRjCEyn1duTiv-1IcZA06Rd9wLcnoK9FU,7647
42
+ dbt_platform_helper/templates/addons/env/s3.yml,sha256=E0ikzN7ztk61rPjUXoKbAujgWcm6MRiDfHzShflBQPA,7758
43
43
  dbt_platform_helper/templates/addons/env/vpc.yml,sha256=Bi-RDr58u-X5J6VHRUxSKDCJ0ddbY79gec6kB69sz8w,3679
44
44
  dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml,sha256=nBIXV4um4jIvXs3Q5QycHqVpJODK5yg_M-xJT6AOBKE,977
45
45
  dbt_platform_helper/templates/addons/svc/prometheus-policy.yml,sha256=cxt0N_MVs-29IX213B6H64-5aWVQNDUR5UnYbLlhX2I,1032
@@ -93,11 +93,11 @@ dbt_platform_helper/utils/manifests.py,sha256=ji3UYHCxq9tTpkm4MlRa2y0-JOYYqq1pWZ
93
93
  dbt_platform_helper/utils/messages.py,sha256=aLx6s9utt__IqlDdeIYq4n82ERwludu2Zfqy0Q2t-x8,115
94
94
  dbt_platform_helper/utils/platform_config.py,sha256=dEGB6peHB1ywYSdS71JGxbWIuTFRaeQfWelksX9v6bQ,608
95
95
  dbt_platform_helper/utils/template.py,sha256=raRx4QUCVJtKfvJK08Egg6gwWcs3r3V4nPWcJW4xNhA,574
96
- dbt_platform_helper/utils/validation.py,sha256=HhBBDEhvw0hExVRG2d4QiUCXSje_rwcuzlIlEuGIKPQ,23719
96
+ dbt_platform_helper/utils/validation.py,sha256=_1bAnM4GG1MM2xXSGs0IQE2Vwaa-GkueROltIK6Wce8,23725
97
97
  dbt_platform_helper/utils/versioning.py,sha256=h3veQpFoiOjYY9dRVppcBDzVfgZerT0lXuE9QCTo5-c,10710
98
98
  platform_helper.py,sha256=zjsZKcbyrEQbKfERi0JG8JEL-MgG6EjxIMiWT66kCVg,2299
99
- dbt_platform_helper-10.9.0.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
- dbt_platform_helper-10.9.0.dist-info/METADATA,sha256=hf8P7QL-hx9qYMtIuqBg56GFfje0p8RT_BApXhSy-Hc,3126
101
- dbt_platform_helper-10.9.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
- dbt_platform_helper-10.9.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
- dbt_platform_helper-10.9.0.dist-info/RECORD,,
99
+ dbt_platform_helper-10.10.0.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
+ dbt_platform_helper-10.10.0.dist-info/METADATA,sha256=EmVJYENHMaKlcdGSzBcWke2zNzTgtV_O_L3DFrqSAIU,3127
101
+ dbt_platform_helper-10.10.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
+ dbt_platform_helper-10.10.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
+ dbt_platform_helper-10.10.0.dist-info/RECORD,,