dbt-platform-helper 12.2.1__py3-none-any.whl → 12.2.3__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.

@@ -71,7 +71,7 @@ def get_vpc_id(session, env_name, vpc_name=None):
71
71
  return vpcs[0]["VpcId"]
72
72
 
73
73
 
74
- def get_subnet_ids(session, vpc_id):
74
+ def get_subnet_ids(session, vpc_id, environment_name):
75
75
  subnets = session.client("ec2").describe_subnets(
76
76
  Filters=[{"Name": "vpc-id", "Values": [vpc_id]}]
77
77
  )["Subnets"]
@@ -81,11 +81,41 @@ def get_subnet_ids(session, vpc_id):
81
81
  raise click.Abort
82
82
 
83
83
  public_tag = {"Key": "subnet_type", "Value": "public"}
84
- public = [subnet["SubnetId"] for subnet in subnets if public_tag in subnet["Tags"]]
84
+ public_subnets = [subnet["SubnetId"] for subnet in subnets if public_tag in subnet["Tags"]]
85
85
  private_tag = {"Key": "subnet_type", "Value": "private"}
86
- private = [subnet["SubnetId"] for subnet in subnets if private_tag in subnet["Tags"]]
86
+ private_subnets = [subnet["SubnetId"] for subnet in subnets if private_tag in subnet["Tags"]]
87
+
88
+ # This call and the method declaration can be removed when we stop using AWS Copilot to deploy the services
89
+ public_subnets, private_subnets = _match_subnet_id_order_to_cloudformation_exports(
90
+ session,
91
+ environment_name,
92
+ public_subnets,
93
+ private_subnets,
94
+ )
95
+
96
+ return public_subnets, private_subnets
97
+
98
+
99
+ def _match_subnet_id_order_to_cloudformation_exports(
100
+ session, environment_name, public_subnets, private_subnets
101
+ ):
102
+ public_subnet_exports = []
103
+ private_subnet_exports = []
104
+ for page in session.client("cloudformation").get_paginator("list_exports").paginate():
105
+ for export in page["Exports"]:
106
+ if f"-{environment_name}-" in export["Name"]:
107
+ if export["Name"].endswith("-PublicSubnets"):
108
+ public_subnet_exports = export["Value"].split(",")
109
+ if export["Name"].endswith("-PrivateSubnets"):
110
+ private_subnet_exports = export["Value"].split(",")
111
+
112
+ # If the elements match, regardless of order, use the list from the CloudFormation exports
113
+ if set(public_subnets) == set(public_subnet_exports):
114
+ public_subnets = public_subnet_exports
115
+ if set(private_subnets) == set(private_subnet_exports):
116
+ private_subnets = private_subnet_exports
87
117
 
88
- return public, private
118
+ return public_subnets, private_subnets
89
119
 
90
120
 
91
121
  def get_cert_arn(session, application, env_name):
@@ -142,22 +172,26 @@ def generate_terraform(name, terraform_platform_modules_version):
142
172
  )
143
173
 
144
174
 
145
- def _generate_copilot_environment_manifests(name, application, env_config, session):
175
+ def _generate_copilot_environment_manifests(environment_name, application, env_config, session):
146
176
  env_template = setup_templates().get_template("env/manifest.yml")
147
177
  vpc_name = env_config.get("vpc", None)
148
- vpc_id = get_vpc_id(session, name, vpc_name)
149
- pub_subnet_ids, priv_subnet_ids = get_subnet_ids(session, vpc_id)
150
- cert_arn = get_cert_arn(session, application, name)
178
+ vpc_id = get_vpc_id(session, environment_name, vpc_name)
179
+ pub_subnet_ids, priv_subnet_ids = get_subnet_ids(session, vpc_id, environment_name)
180
+ cert_arn = get_cert_arn(session, application, environment_name)
151
181
  contents = env_template.render(
152
182
  {
153
- "name": name,
183
+ "name": environment_name,
154
184
  "vpc_id": vpc_id,
155
185
  "pub_subnet_ids": pub_subnet_ids,
156
186
  "priv_subnet_ids": priv_subnet_ids,
157
187
  "certificate_arn": cert_arn,
158
188
  }
159
189
  )
160
- click.echo(mkfile(".", f"copilot/environments/{name}/manifest.yml", contents, overwrite=True))
190
+ click.echo(
191
+ mkfile(
192
+ ".", f"copilot/environments/{environment_name}/manifest.yml", contents, overwrite=True
193
+ )
194
+ )
161
195
 
162
196
 
163
197
  def _generate_terraform_environment_manifests(
@@ -144,7 +144,7 @@ class Codebase:
144
144
  if not application.environments.get(env):
145
145
  raise ApplicationEnvironmentNotFoundError()
146
146
 
147
- json.loads(self.check_codebase_exists_fn(session, application, codebase))
147
+ self.check_codebase_exists_fn(session, application, codebase)
148
148
 
149
149
  self.check_image_exists_fn(session, application, codebase, commit)
150
150
 
@@ -488,13 +488,16 @@ def start_build_extraction(codebuild_client, build_options):
488
488
  def check_codebase_exists(session: Session, application, codebase: str):
489
489
  try:
490
490
  ssm_client = session.client("ssm")
491
- ssm_client.get_parameter(
492
- Name=f"/copilot/applications/{application.name}/codebases/{codebase}"
493
- )["Parameter"]["Value"]
491
+ json.loads(
492
+ ssm_client.get_parameter(
493
+ Name=f"/copilot/applications/{application.name}/codebases/{codebase}"
494
+ )["Parameter"]["Value"]
495
+ )
494
496
  except (
495
497
  KeyError,
496
498
  ValueError,
497
499
  ssm_client.exceptions.ParameterNotFound,
500
+ json.JSONDecodeError,
498
501
  ):
499
502
  raise CopilotCodebaseNotFoundError
500
503
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-platform-helper
3
- Version: 12.2.1
3
+ Version: 12.2.3
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
@@ -10,7 +10,7 @@ dbt_platform_helper/commands/conduit.py,sha256=nOfyqZoF0Q3uYicTwfMXf4FGYC7cR1du-
10
10
  dbt_platform_helper/commands/config.py,sha256=NOHea7OAjrl6XHlW6HMLn0m0T5lFPyNH3HXoyCOWsJk,12070
11
11
  dbt_platform_helper/commands/copilot.py,sha256=i7FLSF-p9P5JQ36e_V8THXxdXG_g1hI7fHxemxQG82A,12927
12
12
  dbt_platform_helper/commands/database.py,sha256=_HnuOxlfVIFGkDotGv0SGb6oWrnm517FSvLv0aGcLJQ,3542
13
- dbt_platform_helper/commands/environment.py,sha256=3HALcatJMJ1-7WmHwnfazh6ulBlwtz0L7cfifDVVPtQ,7751
13
+ dbt_platform_helper/commands/environment.py,sha256=-j-PYLHlrMH4F-DLhCCF3AYKP5z-Tzw7E8SbjMsMPnE,9209
14
14
  dbt_platform_helper/commands/generate.py,sha256=YLCPb-xcPapGcsLn-7d1Am7BpGp5l0iecIDTOdNGjHk,722
15
15
  dbt_platform_helper/commands/notify.py,sha256=kVJ0s78QMiaEWPVKu_bbMko4DW2uJy2fu8-HNJsglyk,3748
16
16
  dbt_platform_helper/commands/pipeline.py,sha256=_52bDSDa8DoyOA4VFxFJhwaiKCPHKqPtK2LWDLFaKlA,9452
@@ -19,7 +19,7 @@ dbt_platform_helper/commands/version.py,sha256=XVfSd53TDti4cceBqTmRfq_yZnvxs14Rb
19
19
  dbt_platform_helper/constants.py,sha256=HVaaO7hlQB41GrBBxcgk7hHie9tKbeYhJc-cRyYuIE0,453
20
20
  dbt_platform_helper/default-extensions.yml,sha256=SU1ZitskbuEBpvE7efc3s56eAUF11j70brhj_XrNMMo,493
21
21
  dbt_platform_helper/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- dbt_platform_helper/domain/codebase.py,sha256=sWmjkKSYh7SnuFFoLtStI6_aYwvncnoAs3xzZZctQY4,9432
22
+ dbt_platform_helper/domain/codebase.py,sha256=_Qx6WZs-16C3Ax0gEbbtPBbl0MNmuxm2Vd42bpc8AZs,9420
23
23
  dbt_platform_helper/domain/conduit.py,sha256=nzkeFCRwEuI5QK092H50l6o2CDD4ZuCuTXLDDmsTNd4,7207
24
24
  dbt_platform_helper/domain/database_copy.py,sha256=QUw8XeUzcKccu4U33b9AKSOwCuGsONIzdmInlOzsmA4,8525
25
25
  dbt_platform_helper/domain/maintenance_page.py,sha256=NFHN_J0NthhJ1YkcOTJ8c0R8y33TrDZq3ka2fmMRM1g,15708
@@ -74,7 +74,7 @@ dbt_platform_helper/templates/svc/overrides/cfn.patches.yml,sha256=W7-d017akuUq9
74
74
  dbt_platform_helper/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
75
  dbt_platform_helper/utils/application.py,sha256=C-t8LIFqE-rrVBNqWEGRtCd6uOt41Y2t0z9_SEZm7oE,4127
76
76
  dbt_platform_helper/utils/arn_parser.py,sha256=1jY0elpAe4YL3ulrrCf1YiKmjI-7YXz4gJASqkIFHTc,1294
77
- dbt_platform_helper/utils/aws.py,sha256=TkgDBelEcfBKQwiYiYZD1RMCxC4tZkRn0PyLyiM19Eo,18555
77
+ dbt_platform_helper/utils/aws.py,sha256=Vs92jcQOJt8aL3xfnfUVX6AiQ2hRfYsf3n6eBsXjbi0,18627
78
78
  dbt_platform_helper/utils/click.py,sha256=Fx4y4bbve1zypvog_sgK7tJtCocmzheoEFLBRv1lfdM,2943
79
79
  dbt_platform_helper/utils/cloudfoundry.py,sha256=GnQ4fVLnDfOdNSrsJjI6ElZHqpgwINeoPn77cUH2UFY,484
80
80
  dbt_platform_helper/utils/files.py,sha256=pa5uwwrEFIAgXZUyH2KEr2Yiu6bKuV4EMlhn9BcUMsY,5296
@@ -86,8 +86,8 @@ dbt_platform_helper/utils/template.py,sha256=raRx4QUCVJtKfvJK08Egg6gwWcs3r3V4nPW
86
86
  dbt_platform_helper/utils/validation.py,sha256=TYLEVdTPBFArnodS9Z7V72qxZJ37GIJto3EXKuBiXFU,28944
87
87
  dbt_platform_helper/utils/versioning.py,sha256=IBxdocJ8ZyJib38d1ja87tTuFE0iJ4npaDcAHQAKQ58,10825
88
88
  platform_helper.py,sha256=bly3JkwbfwnWTZSZziu40dbgzQItsK-DIMMvL6ArFDY,1893
89
- dbt_platform_helper-12.2.1.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
90
- dbt_platform_helper-12.2.1.dist-info/METADATA,sha256=gqoQ37ao1UyKerjLM6Ssic-554F8PNeAEhkYv_rtgRk,3212
91
- dbt_platform_helper-12.2.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
92
- dbt_platform_helper-12.2.1.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
93
- dbt_platform_helper-12.2.1.dist-info/RECORD,,
89
+ dbt_platform_helper-12.2.3.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
90
+ dbt_platform_helper-12.2.3.dist-info/METADATA,sha256=vl8LPxxm63TcuE74ix6QX3LaLgvhhDpcwejeblu5TO4,3212
91
+ dbt_platform_helper-12.2.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
92
+ dbt_platform_helper-12.2.3.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
93
+ dbt_platform_helper-12.2.3.dist-info/RECORD,,