dbt-platform-helper 15.7.0__tar.gz → 15.9.0__tar.gz

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.

Files changed (111) hide show
  1. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/PKG-INFO +3 -13
  2. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/application.py +2 -1
  3. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/constants.py +2 -2
  4. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/maintenance_page.py +25 -3
  5. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/pipelines.py +25 -8
  6. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/entities/platform_config_schema.py +12 -4
  7. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/entities/service.py +1 -1
  8. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/load_balancers.py +3 -2
  9. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/terraform_manifest.py +22 -7
  10. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/yaml_file.py +27 -0
  11. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/environment-pipelines/main.tf +2 -2
  12. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/pyproject.toml +9 -14
  13. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/LICENSE +0 -0
  14. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/COMMANDS.md +0 -0
  15. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/README.md +0 -0
  16. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/__init__.py +0 -0
  17. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/__init__.py +0 -0
  18. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/codebase.py +0 -0
  19. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/conduit.py +0 -0
  20. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/config.py +0 -0
  21. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/copilot.py +0 -0
  22. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/database.py +0 -0
  23. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/environment.py +0 -0
  24. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/generate.py +0 -0
  25. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/notify.py +0 -0
  26. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/pipeline.py +0 -0
  27. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/secrets.py +0 -0
  28. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/service.py +0 -0
  29. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/commands/version.py +0 -0
  30. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/default-extensions.yml +0 -0
  31. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/__init__.py +0 -0
  32. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/codebase.py +0 -0
  33. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/conduit.py +0 -0
  34. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/config.py +0 -0
  35. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/copilot.py +0 -0
  36. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/copilot_environment.py +0 -0
  37. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/database_copy.py +0 -0
  38. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/notify.py +0 -0
  39. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/plans.py +0 -0
  40. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/service.py +0 -0
  41. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/terraform_environment.py +0 -0
  42. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/domain/versioning.py +0 -0
  43. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/entities/semantic_version.py +0 -0
  44. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/jinja2_tags.py +0 -0
  45. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/platform_exception.py +0 -0
  46. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/__init__.py +0 -0
  47. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/__init__.py +0 -0
  48. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/exceptions.py +0 -0
  49. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/interfaces.py +0 -0
  50. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/opensearch.py +0 -0
  51. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/redis.py +0 -0
  52. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/aws/sso_auth.py +0 -0
  53. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/cache.py +0 -0
  54. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/cloudformation.py +0 -0
  55. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/config.py +0 -0
  56. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/config_validator.py +0 -0
  57. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/copilot.py +0 -0
  58. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/ecr.py +0 -0
  59. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/ecs.py +0 -0
  60. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/environment_variable.py +0 -0
  61. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/files.py +0 -0
  62. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/io.py +0 -0
  63. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/kms.py +0 -0
  64. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/parameter_store.py +0 -0
  65. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/schema_migrations/__init__.py +0 -0
  66. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/schema_migrations/schema_v0_to_v1_migration.py +0 -0
  67. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/schema_migrator.py +0 -0
  68. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/secrets.py +0 -0
  69. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/slack_channel_notifier.py +0 -0
  70. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/validation.py +0 -0
  71. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/version.py +0 -0
  72. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/version_status.py +0 -0
  73. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/providers/vpc.py +0 -0
  74. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/config.yml +0 -0
  75. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/image_build_run.sh +0 -0
  76. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/phases/build.sh +0 -0
  77. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/phases/install.sh +0 -0
  78. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/phases/post_build.sh +0 -0
  79. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/.copilot/phases/pre_build.sh +0 -0
  80. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/COMMANDS.md.jinja +0 -0
  81. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addon-instructions.txt +0 -0
  82. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/README.md +0 -0
  83. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml +0 -0
  84. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/svc/prometheus-policy.yml +0 -0
  85. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/svc/s3-cross-account-policy.yml +0 -0
  86. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/svc/s3-policy.yml +0 -0
  87. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/addons/svc/subscription-filter.yml +0 -0
  88. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/ci-codebuild-role-policy.json +0 -0
  89. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/create-codebuild-role.json +0 -0
  90. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/custom-codebuild-role-policy.json +0 -0
  91. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/env/manifest.yml +0 -0
  92. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/env/terraform-overrides/cfn.patches.yml +0 -0
  93. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/svc/maintenance_pages/default.html +0 -0
  94. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/svc/maintenance_pages/dmas-migration.html +0 -0
  95. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/svc/maintenance_pages/migration.html +0 -0
  96. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/templates/svc/overrides/cfn.patches.yml +0 -0
  97. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utilities/decorators.py +0 -0
  98. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/__init__.py +0 -0
  99. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/application.py +0 -0
  100. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/arn_parser.py +0 -0
  101. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/aws.py +0 -0
  102. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/click.py +0 -0
  103. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/deep_merge.py +0 -0
  104. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/git.py +0 -0
  105. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/messages.py +0 -0
  106. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/template.py +0 -0
  107. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/dbt_platform_helper/utils/validation.py +0 -0
  108. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/platform_helper.py +0 -0
  109. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/terraform/elasticache-redis/plans.yml +0 -0
  110. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/terraform/opensearch/plans.yml +0 -0
  111. {dbt_platform_helper-15.7.0 → dbt_platform_helper-15.9.0}/terraform/postgres/plans.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbt-platform-helper
3
- Version: 15.7.0
3
+ Version: 15.9.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
@@ -13,27 +13,17 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Requires-Dist: Jinja2 (==3.1.6)
16
- Requires-Dist: PyYAML (==6.0.2)
17
- Requires-Dist: aiohttp (>=3.11.16,<4.0.0)
18
16
  Requires-Dist: boto3 (>=1.35.2,<2.0.0)
19
- Requires-Dist: boto3-stubs (>=1.26.148,<2.0.0)
20
17
  Requires-Dist: botocore (>=1.34.85,<2.0.0)
21
- Requires-Dist: certifi (>=2023.7.22,<2025.0.0)
22
- Requires-Dist: cfn-flip (==1.3.0)
23
- Requires-Dist: cfn-lint (>=1.4.2,<2.0.0)
24
- Requires-Dist: checkov (>=3.2.405,<4.0.0)
18
+ Requires-Dist: cfn-flip (>=1.3.0,<2.0.0)
25
19
  Requires-Dist: click (>=8.1.3,<9.0.0)
26
- Requires-Dist: cryptography (>=44.0.1,<45)
27
20
  Requires-Dist: jinja2-simple-tags (>=0.5.0,<0.6.0)
28
- Requires-Dist: jsonschema (>=4.17.0,<4.18.0)
29
- Requires-Dist: mypy-boto3-codebuild (>=1.26.0.post1,<2.0.0)
30
21
  Requires-Dist: prettytable (>=3.9.0,<4.0.0)
31
22
  Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
23
+ Requires-Dist: pydantic (>=2.11.7,<3.0.0)
32
24
  Requires-Dist: requests (>=2.31.0,<3.0.0)
33
25
  Requires-Dist: schema (==0.7.5)
34
- Requires-Dist: semver (>=3.0.2,<4.0.0)
35
26
  Requires-Dist: slack-sdk (>=3.27.1,<4.0.0)
36
- Requires-Dist: tomlkit (>=0.12.2,<0.14.0)
37
27
  Requires-Dist: yamllint (>=1.35.1,<2.0.0)
38
28
  Description-Content-Type: text/markdown
39
29
 
@@ -281,12 +281,13 @@ def task_stats(env, app, disk, storage, network):
281
281
  memory,
282
282
  dsk,
283
283
  ) in cpu_response["results"]:
284
+ cpu_value = f"{float(cpu['value']):.1f}" + "%"
284
285
  values = [
285
286
  f"{YELLOW}{taskdef['value'].split('-')[-1]}",
286
287
  f"{YELLOW}{task['value']}",
287
288
  f"{YELLOW}{task_def_revision['value']}",
288
289
  f"{YELLOW}{status['value']}",
289
- f"{YELLOW}{'%.1f' % float(cpu['value']) + '%'}",
290
+ f"{YELLOW}{cpu_value}",
290
291
  f"{YELLOW}{memory['value'] + 'M'}",
291
292
  ]
292
293
 
@@ -16,8 +16,8 @@ TERRAFORM_ECS_SERVICE_MODULE_SOURCE_OVERRIDE_ENV_VAR = (
16
16
  TERRAFORM_MODULE_SOURCE_TYPE_ENV_VAR = "TERRAFORM_MODULE_SOURCE_TYPE" # "LOCAL", "SSH", "OVERRIDE"
17
17
  IMAGE_TAG_ENV_VAR = "IMAGE_TAG"
18
18
  PLATFORM_HELPER_PACKAGE_NAME = "dbt-platform-helper"
19
- SUPPORTED_TERRAFORM_VERSION = "~> 1.8"
20
- SUPPORTED_AWS_PROVIDER_VERSION = "~> 5"
19
+ SUPPORTED_TERRAFORM_VERSION = "~> 1.11"
20
+ SUPPORTED_AWS_PROVIDER_VERSION = "~> 6"
21
21
  FIRST_UPGRADABLE_PLATFORM_HELPER_MAJOR_VERSION = 13
22
22
 
23
23
  MERGED_TPM_PLATFORM_HELPER_VERSION = 14
@@ -199,7 +199,13 @@ class MaintenancePage:
199
199
  "AllowedIps",
200
200
  next(rule_priority),
201
201
  service_conditions,
202
- [{"Key": "service", "Value": svc.name}],
202
+ [
203
+ {"Key": "application", "Value": app},
204
+ {"Key": "environment", "Value": env},
205
+ {"Key": "reason", "Value": "MaintenancePage"},
206
+ {"Key": "managed-by", "Value": "DBT Platform"},
207
+ {"Key": "service", "Value": svc.name},
208
+ ],
203
209
  )
204
210
  self.load_balancer.create_source_ip_rule(
205
211
  listener_arn,
@@ -208,7 +214,13 @@ class MaintenancePage:
208
214
  "AllowedSourceIps",
209
215
  next(rule_priority),
210
216
  service_conditions,
211
- [{"Key": "service", "Value": svc.name}],
217
+ [
218
+ {"Key": "application", "Value": app},
219
+ {"Key": "environment", "Value": env},
220
+ {"Key": "reason", "Value": "MaintenancePage"},
221
+ {"Key": "managed-by", "Value": "DBT Platform"},
222
+ {"Key": "service", "Value": svc.name},
223
+ ],
212
224
  )
213
225
 
214
226
  self.load_balancer.create_header_rule(
@@ -219,7 +231,13 @@ class MaintenancePage:
219
231
  "BypassIpFilter",
220
232
  next(rule_priority),
221
233
  service_conditions,
222
- [{"Key": "service", "Value": svc.name}],
234
+ [
235
+ {"Key": "application", "Value": app},
236
+ {"Key": "environment", "Value": env},
237
+ {"Key": "reason", "Value": "MaintenancePage"},
238
+ {"Key": "managed-by", "Value": "DBT Platform"},
239
+ {"Key": "service", "Value": svc.name},
240
+ ],
223
241
  )
224
242
 
225
243
  # add to accumilating list of conditions for maintenace page rule
@@ -267,8 +285,12 @@ class MaintenancePage:
267
285
  }
268
286
  ],
269
287
  tags=[
288
+ {"Key": "application", "Value": app},
289
+ {"Key": "environment", "Value": env},
290
+ {"Key": "reason", "Value": "MaintenancePage"},
270
291
  {"Key": "name", "Value": "MaintenancePage"},
271
292
  {"Key": "type", "Value": template},
293
+ {"Key": "managed-by", "Value": "DBT Platform"},
272
294
  ],
273
295
  )
274
296
  except Exception as e:
@@ -54,6 +54,25 @@ class Pipelines:
54
54
  or self.environment_variable_provider.get(PLATFORM_HELPER_VERSION_OVERRIDE_KEY)
55
55
  )
56
56
 
57
+ def _map_environment_pipeline_accounts(self, platform_config) -> list[tuple[str, str]]:
58
+ environment_pipelines_config = platform_config[ENVIRONMENT_PIPELINES_KEY]
59
+ environment_config = platform_config["environments"]
60
+
61
+ account_id_lookup = {
62
+ env["accounts"]["deploy"]["name"]: env["accounts"]["deploy"]["id"]
63
+ for env in environment_config.values()
64
+ if env is not None and "accounts" in env and "deploy" in env["accounts"]
65
+ }
66
+
67
+ accounts = set()
68
+
69
+ for config in environment_pipelines_config.values():
70
+ account = config.get("account")
71
+ deploy_account_id = account_id_lookup.get(account)
72
+ accounts.add((account, deploy_account_id))
73
+
74
+ return list(accounts)
75
+
57
76
  def generate(
58
77
  self,
59
78
  deploy_branch: str,
@@ -107,20 +126,16 @@ class Pipelines:
107
126
  )
108
127
 
109
128
  if has_environment_pipelines:
110
- environment_pipelines = platform_config[ENVIRONMENT_PIPELINES_KEY]
111
- accounts = {
112
- config.get("account")
113
- for config in environment_pipelines.values()
114
- if "account" in config
115
- }
129
+ accounts = self._map_environment_pipeline_accounts(platform_config)
116
130
 
117
- for account in accounts:
131
+ for account_name, account_id in accounts:
118
132
  self._generate_terraform_environment_pipeline_manifest(
119
133
  platform_config["application"],
120
134
  deploy_repository,
121
- account,
135
+ account_name,
122
136
  env_pipeline_module_source,
123
137
  deploy_branch,
138
+ account_id,
124
139
  )
125
140
 
126
141
  if has_codebase_pipelines:
@@ -163,6 +178,7 @@ class Pipelines:
163
178
  aws_account: str,
164
179
  module_source: str,
165
180
  deploy_branch: str,
181
+ aws_account_id: str,
166
182
  ):
167
183
  env_pipeline_template = setup_templates().get_template("environment-pipelines/main.tf")
168
184
 
@@ -175,6 +191,7 @@ class Pipelines:
175
191
  "deploy_branch": deploy_branch,
176
192
  "terraform_version": SUPPORTED_TERRAFORM_VERSION,
177
193
  "aws_provider_version": SUPPORTED_AWS_PROVIDER_VERSION,
194
+ "deploy_account_id": aws_account_id,
178
195
  }
179
196
  )
180
197
 
@@ -410,11 +410,19 @@ class PlatformConfigSchema:
410
410
  Optional("environments"): {
411
411
  Optional(PlatformConfigSchema.__valid_environment_name()): {
412
412
  "team_name": str,
413
- "contact_name": str,
414
- "contact_email": str,
415
- "documentation_url": str,
413
+ Optional("contact_name"): str,
414
+ Optional("contact_email"): str,
415
+ Optional("contacts"): [
416
+ {
417
+ "name": str,
418
+ "type": str,
419
+ "contact": str,
420
+ }
421
+ ],
422
+ Optional("documentation_url"): str,
416
423
  "services_to_monitor": dict,
417
- }
424
+ Optional("description"): str,
425
+ },
418
426
  },
419
427
  }
420
428
 
@@ -54,7 +54,7 @@ class SidecarOverride(BaseModel):
54
54
  class Image(BaseModel):
55
55
  build: Optional[str] = Field(default=None)
56
56
  location: Optional[str] = Field(default=None)
57
- port: int = Field()
57
+ port: Optional[int] = Field(default=None)
58
58
 
59
59
 
60
60
  class VPC(BaseModel):
@@ -149,8 +149,9 @@ class LoadBalancerProvider:
149
149
 
150
150
  for rule in rules:
151
151
  for action in rule["Actions"]:
152
- if action["Type"] == "forward" and action["TargetGroupArn"] == target_group_arn:
153
- conditions = rule["Conditions"]
152
+ if "TargetGroupArn" in action:
153
+ if action["Type"] == "forward" and action["TargetGroupArn"] == target_group_arn:
154
+ conditions = rule["Conditions"]
154
155
 
155
156
  if not conditions:
156
157
  raise ListenerRuleConditionsNotFoundException(listener_arn)
@@ -30,6 +30,7 @@ class TerraformManifestProvider:
30
30
  service_dir = f"terraform/services/{environment}/{config_object.name}"
31
31
  platform_config = ConfigProvider.apply_environment_defaults(platform_config)
32
32
  account = self._get_account_for_env(environment, platform_config)
33
+ deploy_to_account_id = self._get_account_id_for_account(account, platform_config)
33
34
  state_key_suffix = f"{config_object.name}-{environment}"
34
35
 
35
36
  terraform = {}
@@ -37,7 +38,7 @@ class TerraformManifestProvider:
37
38
 
38
39
  self._add_service_locals(terraform, environment, image_tag)
39
40
 
40
- self._add_provider(terraform, account)
41
+ self._add_provider(terraform, account, deploy_to_account_id)
41
42
  self._add_backend(
42
43
  terraform, platform_config, account, f"tfstate/services/{state_key_suffix}.tfstate"
43
44
  )
@@ -54,11 +55,13 @@ class TerraformManifestProvider:
54
55
  "application": '${local.platform_config["application"]}',
55
56
  "environments": '${local.platform_config["environments"]}',
56
57
  "env_config": '${{for name, config in local.environments: name => merge(lookup(local.environments, "*", {}), config)}}',
57
- "service_config": '${yamldecode(templatefile("./service-config.yml", {COPILOT_ENVIRONMENT_NAME = local.environment, IMAGE_TAG = local.image_tag}))}',
58
+ "service_config": '${yamldecode(templatefile("./service-config.yml", {PLATFORM_ENVIRONMENT_NAME = local.environment, IMAGE_TAG = local.image_tag}))}',
58
59
  "raw_env_config": '${local.platform_config["environments"]}',
59
60
  "combined_env_config": '${{for name, config in local.raw_env_config: name => merge(lookup(local.raw_env_config, "*", {}), config)}}',
60
61
  "service_deployment_mode": '${lookup(local.combined_env_config[local.environment], "service-deployment-mode", "copilot")}',
61
62
  "non_copilot_service_deployment_mode": '${local.service_deployment_mode == "dual-deploy-copilot-traffic" || local.service_deployment_mode == "dual-deploy-platform-traffic" || local.service_deployment_mode == "platform" ? 1 : 0}',
63
+ "custom_iam_policy_path": '${abspath(format("%s/../../../../services/%s/custom-iam-policy/%s.yml", path.module, local.service_config.name, local.environment))}',
64
+ "custom_iam_policy_json": "${fileexists(local.custom_iam_policy_path) ? jsonencode(yamldecode(file(local.custom_iam_policy_path))) : null}",
62
65
  }
63
66
 
64
67
  def _add_service_module(
@@ -76,6 +79,8 @@ class TerraformManifestProvider:
76
79
  "environment": "${local.environment}",
77
80
  "service_config": "${local.service_config}",
78
81
  "env_config": "${local.env_config}",
82
+ "platform_extensions": '${local.platform_config["extensions"]}',
83
+ "custom_iam_policy_json": "${local.custom_iam_policy_json}",
79
84
  }
80
85
  }
81
86
 
@@ -88,12 +93,13 @@ class TerraformManifestProvider:
88
93
  module_source: str,
89
94
  ):
90
95
  default_account = self._get_account_for_env("*", platform_config)
96
+ deploy_to_account_id = self._get_account_id_for_account(default_account, platform_config)
91
97
  state_key_suffix = f"{platform_config['application']}-codebase-pipelines"
92
98
 
93
99
  terraform = {}
94
100
  self._add_header(terraform)
95
101
  self._add_codebase_pipeline_locals(terraform)
96
- self._add_provider(terraform, default_account)
102
+ self._add_provider(terraform, default_account, deploy_to_account_id)
97
103
  self._add_backend(
98
104
  terraform,
99
105
  platform_config,
@@ -142,6 +148,16 @@ class TerraformManifestProvider:
142
148
  )
143
149
  return account
144
150
 
151
+ @staticmethod
152
+ def _get_account_id_for_account(account_name, platform_config):
153
+ environment_config = platform_config["environments"]
154
+ account_id_lookup = {
155
+ env["accounts"]["deploy"]["name"]: env["accounts"]["deploy"]["id"]
156
+ for env in environment_config.values()
157
+ if env is not None and "accounts" in env and "deploy" in env["accounts"]
158
+ }
159
+ return account_id_lookup.get(account_name)
160
+
145
161
  @staticmethod
146
162
  def _add_header(terraform: dict):
147
163
  time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -160,12 +176,11 @@ class TerraformManifestProvider:
160
176
  }
161
177
 
162
178
  @staticmethod
163
- def _add_provider(terraform: dict, default_account: str):
179
+ def _add_provider(terraform: dict, deploy_to_account: str, deploy_to_account_id: str):
164
180
  terraform["provider"] = {"aws": {}}
165
181
  terraform["provider"]["aws"]["region"] = "eu-west-2"
166
- terraform["provider"]["aws"]["profile"] = default_account
167
- terraform["provider"]["aws"]["alias"] = default_account
168
- terraform["provider"]["aws"]["shared_credentials_files"] = ["~/.aws/config"]
182
+ terraform["provider"]["aws"]["profile"] = deploy_to_account
183
+ terraform["provider"]["aws"]["allowed_account_ids"] = [deploy_to_account_id]
169
184
 
170
185
  @staticmethod
171
186
  def _add_backend(terraform: dict, platform_config: dict, account: str, state_key: str):
@@ -1,3 +1,4 @@
1
+ from collections import OrderedDict
1
2
  from pathlib import Path
2
3
 
3
4
  import yaml
@@ -84,6 +85,32 @@ class YamlFileProvider:
84
85
  if duplicate_keys:
85
86
  raise DuplicateKeysException(",".join(duplicate_keys))
86
87
 
88
+ @staticmethod
89
+ def remove_empty_keys(config: (dict, OrderedDict)) -> (dict, OrderedDict):
90
+ cleaned = config.__class__()
91
+
92
+ for k, v in config.items():
93
+ if isinstance(v, (dict, OrderedDict)):
94
+ v = YamlFileProvider.remove_empty_keys(v)
95
+ if v not in ("", None, [], {}, ()):
96
+ cleaned[k] = v
97
+
98
+ return cleaned
99
+
100
+ @staticmethod
101
+ def find_and_replace(config, string: str, replacement: str):
102
+ if isinstance(config, (dict, OrderedDict)):
103
+ return {
104
+ k: YamlFileProvider.find_and_replace(v, string, replacement)
105
+ for k, v in config.items()
106
+ }
107
+ elif isinstance(config, list):
108
+ return [YamlFileProvider.find_and_replace(item, string, replacement) for item in config]
109
+ elif isinstance(config, str):
110
+ return config.replace(string, replacement)
111
+ else:
112
+ return replacement if config == string else config
113
+
87
114
 
88
115
  def account_number_representer(dumper, data):
89
116
  if data.isdigit():
@@ -10,10 +10,10 @@ locals {
10
10
  provider "aws" {
11
11
  region = "eu-west-2"
12
12
  profile = "{{ aws_account }}"
13
- alias = "{{ aws_account }}"
14
- shared_credentials_files = ["~/.aws/config"]
13
+ allowed_account_ids = ["{{ deploy_account_id }}"]
15
14
  }
16
15
 
16
+
17
17
  terraform {
18
18
  required_version = "{{ terraform_version }}"
19
19
  backend "s3" {
@@ -3,7 +3,7 @@ line-length = 100
3
3
 
4
4
  [tool.poetry]
5
5
  name = "dbt-platform-helper"
6
- version = "15.7.0"
6
+ version = "15.9.0"
7
7
  description = "Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot."
8
8
  authors = ["Department for Business and Trade Platform Team <sre-team@digital.trade.gov.uk>"]
9
9
  license = "MIT"
@@ -21,41 +21,36 @@ platform-helper = "platform_helper:platform_helper"
21
21
 
22
22
  [tool.poetry.dependencies]
23
23
  Jinja2 = "3.1.6"
24
- PyYAML = "6.0.2"
25
24
  yamllint = "^1.35.1"
26
25
  boto3 = "^1.35.2"
27
- boto3-stubs = "^1.26.148"
28
26
  botocore = "^1.34.85"
29
27
  click = "^8.1.3"
30
- mypy-boto3-codebuild = "^1.26.0.post1"
31
28
  python = ">3.9.1,<4.0"
32
29
  schema = "0.7.5"
33
- cfn-flip = "1.3.0"
34
- aiohttp = "^3.11.16"
35
- certifi = ">=2023.7.22,<2025.0.0"
36
- cryptography = ">=44.0.1, <45"
37
30
  jinja2-simple-tags = "^0.5.0"
38
31
  requests = "^2.31.0"
39
32
  prettytable = "^3.9.0"
40
- semver = "^3.0.2"
41
- tomlkit = ">=0.12.2,<0.14.0"
42
33
  slack-sdk = "^3.27.1"
43
- jsonschema = "~=4.17.0"
44
- cfn-lint = "^1.4.2"
45
34
  psycopg2-binary = "^2.9.9"
46
- checkov = "^3.2.405"
35
+ pydantic = "^2.11.7"
36
+ cfn-flip = "^1.3.0"
47
37
 
48
38
  [tool.poetry.group.dev.dependencies]
39
+ checkov = "^3.2.405"
49
40
  moto = {extras = ["all"], version = "^5.0.28"}
50
41
  pyfakefs = "^5.2.2"
51
42
  pytest = "^8.3.5"
52
43
  pytest-env = ">=0.8.1,<1.2.0"
53
44
  tox = "^4.6.0"
54
- pre-commit = "^3.3.3"
45
+ pre-commit = ">=3.3.3,<5.0.0"
55
46
  freezegun = "^1.2.2"
56
47
  parameterized = "^0.9.0"
57
48
  pytest-xdist = "^3.5.0"
58
49
  pytest-cov = "^6.0.0"
50
+ mypy-boto3-codebuild = "^1.40.8"
51
+
52
+ python-hcl2 = "^7.3.1"
53
+ boto3-stubs = "^1.26.148"
59
54
 
60
55
  [build-system]
61
56
  requires = ["poetry-core"]