dbt-platform-helper 15.11.0__tar.gz → 15.12.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 (114) hide show
  1. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/PKG-INFO +1 -1
  2. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/internal.py +3 -0
  3. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/constants.py +3 -0
  4. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/conduit.py +12 -4
  5. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/service.py +10 -6
  6. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/load_balancers.py +33 -6
  7. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/application.py +66 -16
  8. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/pyproject.toml +1 -1
  9. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/LICENSE +0 -0
  10. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/COMMANDS.md +0 -0
  11. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/README.md +0 -0
  12. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/__init__.py +0 -0
  13. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/__init__.py +0 -0
  14. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/application.py +0 -0
  15. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/codebase.py +0 -0
  16. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/conduit.py +0 -0
  17. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/config.py +0 -0
  18. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/copilot.py +0 -0
  19. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/database.py +0 -0
  20. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/environment.py +0 -0
  21. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/generate.py +0 -0
  22. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/notify.py +0 -0
  23. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/pipeline.py +0 -0
  24. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/secrets.py +0 -0
  25. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/commands/version.py +0 -0
  26. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/default-extensions.yml +0 -0
  27. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/__init__.py +0 -0
  28. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/codebase.py +0 -0
  29. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/config.py +0 -0
  30. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/copilot.py +0 -0
  31. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/copilot_environment.py +0 -0
  32. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/database_copy.py +0 -0
  33. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/maintenance_page.py +0 -0
  34. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/notify.py +0 -0
  35. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/pipelines.py +0 -0
  36. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/plans.py +0 -0
  37. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/terraform_environment.py +0 -0
  38. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/update_alb_rules.py +0 -0
  39. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/domain/versioning.py +0 -0
  40. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/entities/platform_config_schema.py +0 -0
  41. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/entities/semantic_version.py +0 -0
  42. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/entities/service.py +0 -0
  43. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/jinja2_tags.py +0 -0
  44. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/platform_exception.py +0 -0
  45. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/__init__.py +0 -0
  46. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/__init__.py +0 -0
  47. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/exceptions.py +0 -0
  48. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/interfaces.py +0 -0
  49. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/opensearch.py +0 -0
  50. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/redis.py +0 -0
  51. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/aws/sso_auth.py +0 -0
  52. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/cache.py +0 -0
  53. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/cloudformation.py +0 -0
  54. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/config.py +0 -0
  55. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/config_validator.py +0 -0
  56. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/copilot.py +0 -0
  57. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/ecr.py +0 -0
  58. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/ecs.py +0 -0
  59. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/environment_variable.py +0 -0
  60. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/files.py +0 -0
  61. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/io.py +0 -0
  62. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/kms.py +0 -0
  63. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/logs.py +0 -0
  64. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/parameter_store.py +0 -0
  65. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/s3.py +0 -0
  66. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/schema_migrations/__init__.py +0 -0
  67. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/schema_migrations/schema_v0_to_v1_migration.py +0 -0
  68. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/schema_migrator.py +0 -0
  69. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/secrets.py +0 -0
  70. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/slack_channel_notifier.py +0 -0
  71. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/terraform_manifest.py +0 -0
  72. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/validation.py +0 -0
  73. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/version.py +0 -0
  74. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/version_status.py +0 -0
  75. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/vpc.py +0 -0
  76. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/providers/yaml_file.py +0 -0
  77. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/config.yml +0 -0
  78. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/image_build_run.sh +0 -0
  79. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/phases/build.sh +0 -0
  80. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/phases/install.sh +0 -0
  81. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/phases/post_build.sh +0 -0
  82. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/.copilot/phases/pre_build.sh +0 -0
  83. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/COMMANDS.md.jinja +0 -0
  84. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addon-instructions.txt +0 -0
  85. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/README.md +0 -0
  86. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml +0 -0
  87. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/svc/prometheus-policy.yml +0 -0
  88. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/svc/s3-cross-account-policy.yml +0 -0
  89. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/svc/s3-policy.yml +0 -0
  90. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/addons/svc/subscription-filter.yml +0 -0
  91. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/ci-codebuild-role-policy.json +0 -0
  92. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/create-codebuild-role.json +0 -0
  93. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/custom-codebuild-role-policy.json +0 -0
  94. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/env/manifest.yml +0 -0
  95. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/env/terraform-overrides/cfn.patches.yml +0 -0
  96. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/environment-pipelines/main.tf +0 -0
  97. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/svc/maintenance_pages/default.html +0 -0
  98. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/svc/maintenance_pages/dmas-migration.html +0 -0
  99. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/svc/maintenance_pages/migration.html +0 -0
  100. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/templates/svc/overrides/cfn.patches.yml +0 -0
  101. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utilities/decorators.py +0 -0
  102. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/__init__.py +0 -0
  103. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/arn_parser.py +0 -0
  104. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/aws.py +0 -0
  105. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/click.py +0 -0
  106. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/deep_merge.py +0 -0
  107. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/git.py +0 -0
  108. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/messages.py +0 -0
  109. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/template.py +0 -0
  110. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/dbt_platform_helper/utils/validation.py +0 -0
  111. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/platform_helper.py +0 -0
  112. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/terraform/elasticache-redis/plans.yml +0 -0
  113. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/terraform/opensearch/plans.yml +0 -0
  114. {dbt_platform_helper-15.11.0 → dbt_platform_helper-15.12.0}/terraform/postgres/plans.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbt-platform-helper
3
- Version: 15.11.0
3
+ Version: 15.12.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
  License-File: LICENSE
@@ -74,6 +74,8 @@ def deploy(name, env, image_tag):
74
74
  s3_provider = S3Provider(client=s3_client)
75
75
  logs_provider = LogsProvider(client=logs_client)
76
76
 
77
+ account_id = application.environments.get(env).account_id
78
+
77
79
  service_manager = ServiceManager(
78
80
  ecs_provider=ecs_provider, s3_provider=s3_provider, logs_provider=logs_provider
79
81
  )
@@ -81,6 +83,7 @@ def deploy(name, env, image_tag):
81
83
  service=name,
82
84
  environment=env,
83
85
  application=application.name,
86
+ account_id=account_id,
84
87
  image_tag=image_tag,
85
88
  )
86
89
  except PlatformException as error:
@@ -1,4 +1,5 @@
1
1
  # TODO: DBTP-1888: Move to Config provider
2
+ REPO_ORG = "uktrade"
2
3
  PLATFORM_CONFIG_FILE = "platform-config.yml"
3
4
  SERVICE_DIRECTORY = "services"
4
5
  SERVICE_CONFIG_FILE = "service-config.yml"
@@ -59,3 +60,5 @@ STANDARD_PLATFORM_SSO_ROLES = [
59
60
  "DBTPlatformDeveloperWrite",
60
61
  "DBTPlatformDeveloperRead",
61
62
  ]
63
+ ROUTED_TO_PLATFORM_MODES = ["platform", "dual-deploy-platform-traffic"]
64
+ ROUTED_TO_COPILOT_MODES = ["copilot", "dual-deploy-copilot-traffic"]
@@ -56,10 +56,16 @@ class TerraformConduitStrategy(ConduitECSStrategy):
56
56
 
57
57
  def get_data(self):
58
58
  self.io.info("Starting conduit in Terraform mode.")
59
- return {
60
- "cluster_arn": self.ecs_provider.get_cluster_arn_by_name(
59
+ try:
60
+ cluster_arn = self.ecs_provider.get_cluster_arn_by_name(
61
+ f"{self.application.name}-{self.env}-cluster"
62
+ )
63
+ except:
64
+ cluster_arn = self.ecs_provider.get_cluster_arn_by_name(
61
65
  f"{self.application.name}-{self.env}"
62
- ),
66
+ )
67
+ return {
68
+ "cluster_arn": cluster_arn,
63
69
  "task_def_family": self._generate_container_name(),
64
70
  "vpc_name": self._resolve_vpc_name(),
65
71
  "addon_type": self.addon_type,
@@ -94,8 +100,10 @@ class TerraformConduitStrategy(ConduitECSStrategy):
94
100
  },
95
101
  ]
96
102
 
103
+ cluster_name = data_context["cluster_arn"].split("/")[-1]
104
+
97
105
  self.ecs_provider.start_ecs_task(
98
- f"{self.application.name}-{self.env}",
106
+ cluster_name,
99
107
  self._generate_container_name(),
100
108
  data_context["task_def_family"],
101
109
  vpc_config,
@@ -231,13 +231,17 @@ class ServiceManager:
231
231
  f"{service_path}/service-config.yml", dict(service_manifest), message
232
232
  )
233
233
 
234
- def deploy(self, service: str, environment: str, application: str, image_tag: str = None):
234
+ def deploy(
235
+ self,
236
+ service: str,
237
+ environment: str,
238
+ application: str,
239
+ account_id: str,
240
+ image_tag: str = None,
241
+ ):
235
242
  """Register a new ECS task definition revision, update the ECS service
236
- with it, and output Cloudwatch logs until deployment is complete."""
237
-
238
- application_obj = self.load_application(app=application)
239
- application_envs = application_obj.environments
240
- account_id = application_envs.get(environment).account_id
243
+ with it, output a Cloudwatch logs URL, and wait until deployment is
244
+ complete."""
241
245
 
242
246
  s3_response = self.s3_provider.get_object(
243
247
  bucket_name=f"ecs-task-definitions-{application}-{environment}",
@@ -1,11 +1,14 @@
1
+ import json
1
2
  from typing import Dict
2
3
  from typing import List
3
4
 
4
5
  from boto3 import Session
5
6
 
6
7
  from dbt_platform_helper.constants import MANAGED_BY_PLATFORM_TERRAFORM
8
+ from dbt_platform_helper.constants import ROUTED_TO_PLATFORM_MODES
7
9
  from dbt_platform_helper.platform_exception import PlatformException
8
10
  from dbt_platform_helper.providers.io import ClickIOProvider
11
+ from dbt_platform_helper.providers.parameter_store import ParameterStore
9
12
  from dbt_platform_helper.utils.aws import get_aws_session_or_abort
10
13
 
11
14
 
@@ -33,6 +36,7 @@ class LoadBalancerProvider:
33
36
  self.session = session
34
37
  self.evlb_client = self._get_client("elbv2")
35
38
  self.rg_tagging_client = self._get_client("resourcegroupstaggingapi")
39
+ self.parameter_store_provider = ParameterStore(self._get_client("ssm"))
36
40
  self.io = io
37
41
 
38
42
  def _get_client(self, client: str):
@@ -41,21 +45,44 @@ class LoadBalancerProvider:
41
45
  return self.session.client(client)
42
46
 
43
47
  def find_target_group(self, app: str, env: str, svc: str) -> str:
48
+
49
+ # TODO once copilot is gone this is no longer needed
50
+ try:
51
+ result = self.parameter_store_provider.get_ssm_parameter_by_name(
52
+ f"/platform/applications/{app}/environments/{env}"
53
+ )["Value"]
54
+ env_config = json.loads(result)
55
+ service_deployment_mode = env_config["service_deployment_mode"]
56
+ except Exception:
57
+ service_deployment_mode = "copilot"
58
+
59
+ if service_deployment_mode in ROUTED_TO_PLATFORM_MODES:
60
+ application_key = "application"
61
+ environment_key = "environment"
62
+ service_key = "service"
63
+ else:
64
+ application_key = "copilot-application"
65
+ environment_key = "copilot-environment"
66
+ service_key = "copilot-service"
44
67
  target_group_arn = None
45
68
 
46
69
  paginator = self.rg_tagging_client.get_paginator("get_resources")
47
70
  page_iterator = paginator.paginate(
48
71
  TagFilters=[
49
72
  {
50
- "Key": "copilot-application",
73
+ "Key": application_key,
51
74
  "Values": [
52
75
  app,
53
76
  ],
54
- "Key": "copilot-environment",
77
+ },
78
+ {
79
+ "Key": environment_key,
55
80
  "Values": [
56
81
  env,
57
82
  ],
58
- "Key": "copilot-service",
83
+ },
84
+ {
85
+ "Key": service_key,
59
86
  "Values": [
60
87
  svc,
61
88
  ],
@@ -71,9 +98,9 @@ class LoadBalancerProvider:
71
98
  tags = {tag["Key"]: tag["Value"] for tag in resource["Tags"]}
72
99
 
73
100
  if (
74
- tags.get("copilot-service") == svc
75
- and tags.get("copilot-environment") == env
76
- and tags.get("copilot-application") == app
101
+ tags.get(service_key) == svc
102
+ and tags.get(environment_key) == env
103
+ and tags.get(application_key) == app
77
104
  ):
78
105
  target_group_arn = resource["ResourceARN"]
79
106
 
@@ -74,6 +74,7 @@ def load_application(app=None, default_session=None, env=None) -> Application:
74
74
  nesting.
75
75
 
76
76
  e.g.
77
+ - /platform/applications/test/environments/my_env will match.
77
78
  - /copilot/applications/test/environments/my_env will match.
78
79
  - /copilot/applications/test/environments/my_env/addons will not match.
79
80
  """
@@ -84,20 +85,24 @@ def load_application(app=None, default_session=None, env=None) -> Application:
84
85
 
85
86
  environments_data = []
86
87
 
87
- # Try to load the new /platform SSM parameter if present
88
- platform_env_path = f"/platform/applications/{application.name}/environments"
89
- secrets = get_ssm_secrets(app, None, current_session, platform_env_path)
88
+ # Try to load all /platform SSM parameters that are present
89
+ env_params = get_ssm_secrets(
90
+ app=app,
91
+ env=None,
92
+ session=current_session,
93
+ path=f"/platform/applications/{application.name}/environments",
94
+ )
90
95
 
91
- if secrets:
92
- for name, value in secrets:
96
+ if env_params:
97
+ for name, value in env_params:
93
98
  try:
94
- data = json.loads(value)
99
+ param_data = json.loads(value)
95
100
  except json.JSONDecodeError:
96
101
  continue
97
102
 
98
- # New /platform SSM parameter contains data about all environments
99
- if "allEnvironments" in data:
100
- environments_data = data["allEnvironments"]
103
+ # Each /platform SSM parameter contains data about all the environments of an application
104
+ if "allEnvironments" in param_data:
105
+ environments_data = param_data["allEnvironments"]
101
106
  break # Only need one
102
107
  else:
103
108
  try:
@@ -106,19 +111,20 @@ def load_application(app=None, default_session=None, env=None) -> Application:
106
111
  Name=f"/copilot/applications/{application.name}",
107
112
  WithDecryption=False,
108
113
  )
109
- secrets = get_ssm_secrets(
114
+
115
+ # Legacy /copilot SSM parameters for each environment
116
+ env_params = get_ssm_secrets(
110
117
  app, None, current_session, f"/copilot/applications/{application.name}/environments"
111
118
  )
112
119
 
113
- for name, value in secrets:
120
+ for name, value in env_params:
114
121
  try:
115
- data = json.loads(value)
122
+ param_data = json.loads(value)
116
123
  except json.JSONDecodeError:
117
124
  continue
118
125
 
119
126
  if is_environment_key(name):
120
- # Legacy /copilot SSM parameter. An individual SSM param is present per environment - looping through all of them is needed to extract necessary data about each env.
121
- environments_data.append(data)
127
+ environments_data.append(param_data)
122
128
 
123
129
  except ssm_client.exceptions.ParameterNotFound:
124
130
  raise ApplicationNotFoundException(
@@ -130,6 +136,50 @@ def load_application(app=None, default_session=None, env=None) -> Application:
130
136
  for env in environments_data
131
137
  }
132
138
 
139
+ application.services = _load_services(ssm_client, application)
140
+
141
+ return application
142
+
143
+
144
+ def _load_services(ssm_client, application: Application) -> Dict[str, Service]:
145
+ """
146
+ Try to load
147
+ /platform/applications/{app}/environments/{env}/services/{service}
148
+ parameters if present.
149
+
150
+ Otherwise, fall back to legacy /copilot/applications/{app}/components
151
+ parameters.
152
+ """
153
+ services: Dict[str, Service] = {}
154
+
155
+ # Try /platform SSM parameter
156
+ for env_name in application.environments.keys():
157
+ params = dict(
158
+ Path=f"/platform/applications/{application.name}/environments/{env_name}/services",
159
+ Recursive=False,
160
+ WithDecryption=False,
161
+ )
162
+
163
+ while True:
164
+ response = ssm_client.get_parameters_by_path(**params)
165
+ for ssm_param in response.get("Parameters", []):
166
+ try:
167
+ data = json.loads(ssm_param["Value"])
168
+ name = data["name"]
169
+ kind = data["type"]
170
+ services.setdefault(name, Service(name, kind)) # Avoid duplicates
171
+ except (json.JSONDecodeError, KeyError):
172
+ continue
173
+
174
+ if "NextToken" in response:
175
+ params["NextToken"] = response["NextToken"]
176
+ else:
177
+ break
178
+
179
+ if services:
180
+ return services
181
+
182
+ # Fallback to legacy /copilot SSM parameter
133
183
  response = ssm_client.get_parameters_by_path(
134
184
  Path=f"/copilot/applications/{application.name}/components",
135
185
  Recursive=False,
@@ -145,12 +195,12 @@ def load_application(app=None, default_session=None, env=None) -> Application:
145
195
  )
146
196
  results.extend(response["Parameters"])
147
197
 
148
- application.services = {
198
+ legacy_services = {
149
199
  svc["name"]: Service(svc["name"], svc["type"])
150
200
  for svc in [json.loads(parameter["Value"]) for parameter in results]
151
201
  }
152
202
 
153
- return application
203
+ return legacy_services
154
204
 
155
205
 
156
206
  def get_application_name(abort=abort_with_error):
@@ -3,7 +3,7 @@ line-length = 100
3
3
 
4
4
  [tool.poetry]
5
5
  name = "dbt-platform-helper"
6
- version = "15.11.0"
6
+ version = "15.12.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"