dbt-platform-helper 12.2.2__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(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-platform-helper
3
- Version: 12.2.2
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
@@ -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.2.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
90
- dbt_platform_helper-12.2.2.dist-info/METADATA,sha256=0vT9stcLQEOFuV6SNXbi12AuZZ1tNBVRYr5Iuh6pL78,3212
91
- dbt_platform_helper-12.2.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
92
- dbt_platform_helper-12.2.2.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
93
- dbt_platform_helper-12.2.2.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,,