dbt-platform-helper 12.6.0__tar.gz → 13.0.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 (107) hide show
  1. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/PKG-INFO +1 -1
  2. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/COMMANDS.md +7 -7
  3. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/codebase.py +2 -2
  4. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/notify.py +5 -3
  5. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/pipeline.py +17 -8
  6. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/constants.py +3 -1
  7. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/codebase.py +35 -16
  8. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/config_validator.py +5 -27
  9. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/maintenance_page.py +94 -57
  10. dbt_platform_helper-13.0.0/dbt_platform_helper/domain/pipelines.py +138 -0
  11. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/terraform_environment.py +4 -0
  12. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/aws.py +5 -0
  13. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/config.py +2 -2
  14. dbt_platform_helper-13.0.0/dbt_platform_helper/providers/ecr.py +20 -0
  15. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/files.py +1 -1
  16. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/platform_config_schema.py +14 -15
  17. dbt_platform_helper-13.0.0/dbt_platform_helper/providers/terraform_manifest.py +120 -0
  18. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/environment-pipelines/main.tf +2 -2
  19. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/environments/main.tf +3 -4
  20. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/aws.py +16 -5
  21. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/pyproject.toml +1 -1
  22. dbt_platform_helper-12.6.0/dbt_platform_helper/domain/pipelines.py +0 -212
  23. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/manifest.yml +0 -56
  24. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/.gitignore +0 -12
  25. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/bin/override.ts +0 -8
  26. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.deploy.yml +0 -29
  27. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.image.yml +0 -48
  28. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/cdk.json +0 -20
  29. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/package-lock.json +0 -4428
  30. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/package.json +0 -27
  31. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/stack.ts +0 -521
  32. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/tsconfig.json +0 -30
  33. dbt_platform_helper-12.6.0/dbt_platform_helper/templates/pipelines/codebase/overrides/types.ts +0 -52
  34. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/LICENSE +0 -0
  35. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/README.md +0 -0
  36. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/__init__.py +0 -0
  37. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/addon-plans.yml +0 -0
  38. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/__init__.py +0 -0
  39. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/application.py +0 -0
  40. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/conduit.py +0 -0
  41. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/config.py +0 -0
  42. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/copilot.py +0 -0
  43. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/database.py +0 -0
  44. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/environment.py +0 -0
  45. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/generate.py +0 -0
  46. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/secrets.py +0 -0
  47. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/commands/version.py +0 -0
  48. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/default-extensions.yml +0 -0
  49. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/__init__.py +0 -0
  50. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/conduit.py +0 -0
  51. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/copilot_environment.py +0 -0
  52. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/database_copy.py +0 -0
  53. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/domain/test_platform_terraform_manifest_generator.py +0 -0
  54. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/jinja2_tags.py +0 -0
  55. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/platform_exception.py +0 -0
  56. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/__init__.py +0 -0
  57. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/cache.py +0 -0
  58. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/cloudformation.py +0 -0
  59. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/copilot.py +0 -0
  60. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/ecs.py +0 -0
  61. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/io.py +0 -0
  62. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/load_balancers.py +0 -0
  63. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/opensearch.py +0 -0
  64. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/redis.py +0 -0
  65. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/secrets.py +0 -0
  66. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/validation.py +0 -0
  67. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/vpc.py +0 -0
  68. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/providers/yaml_file.py +0 -0
  69. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/config.yml +0 -0
  70. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/image_build_run.sh +0 -0
  71. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/phases/build.sh +0 -0
  72. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/phases/install.sh +0 -0
  73. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/phases/post_build.sh +0 -0
  74. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/.copilot/phases/pre_build.sh +0 -0
  75. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/COMMANDS.md.jinja +0 -0
  76. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addon-instructions.txt +0 -0
  77. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/README.md +0 -0
  78. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml +0 -0
  79. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/svc/prometheus-policy.yml +0 -0
  80. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/svc/s3-cross-account-policy.yml +0 -0
  81. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/svc/s3-policy.yml +0 -0
  82. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/addons/svc/subscription-filter.yml +0 -0
  83. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/ci-codebuild-role-policy.json +0 -0
  84. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/create-codebuild-role.json +0 -0
  85. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/custom-codebuild-role-policy.json +0 -0
  86. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/env/manifest.yml +0 -0
  87. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/env/terraform-overrides/cfn.patches.yml +0 -0
  88. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/maintenance_pages/default.html +0 -0
  89. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/maintenance_pages/dmas-migration.html +0 -0
  90. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/maintenance_pages/migration.html +0 -0
  91. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/manifest-backend.yml +0 -0
  92. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/manifest-public.yml +0 -0
  93. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/templates/svc/overrides/cfn.patches.yml +0 -0
  94. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/__init__.py +0 -0
  95. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/application.py +0 -0
  96. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/arn_parser.py +0 -0
  97. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/click.py +0 -0
  98. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/cloudfoundry.py +0 -0
  99. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/files.py +0 -0
  100. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/git.py +0 -0
  101. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/manifests.py +0 -0
  102. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/messages.py +0 -0
  103. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/platform_config.py +0 -0
  104. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/template.py +0 -0
  105. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/validation.py +0 -0
  106. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/dbt_platform_helper/utils/versioning.py +0 -0
  107. {dbt_platform_helper-12.6.0 → dbt_platform_helper-13.0.0}/platform_helper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbt-platform-helper
3
- Version: 12.6.0
3
+ Version: 13.0.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
@@ -222,7 +222,7 @@ platform-helper codebase build --app <application> --codebase <codebase>
222
222
  - `--app <text>`
223
223
  - AWS application name
224
224
  - `--codebase <text>`
225
- - The codebase name as specified in the platform-config.yml file
225
+ - The codebase name as specified in the platform-config.yml file. This must be run from your codebase repository directory.
226
226
  - `--commit <text>`
227
227
  - GitHub commit hash
228
228
  - `--help <boolean>` _Defaults to False._
@@ -246,7 +246,7 @@ platform-helper codebase deploy --app <application> --env <environment> --codeba
246
246
  - `--env <text>`
247
247
  - AWS Copilot environment
248
248
  - `--codebase <text>`
249
- - The codebase name as specified in the platform-config.yml file
249
+ - The codebase name as specified in the platform-config.yml file. This can be run from any directory.
250
250
  - `--commit <text>`
251
251
  - GitHub commit hash
252
252
  - `--help <boolean>` _Defaults to False._
@@ -492,7 +492,7 @@ platform-helper environment generate-terraform --name <name> [--terraform-platfo
492
492
  -n <text>`
493
493
  - The name of the environment to generate a manifest for.
494
494
  - `--terraform-platform-modules-version <text>`
495
- - Override the default version of terraform-platform-modules. (Default version is '5').
495
+ - Override the default version of terraform-platform-modules. (Default version is '7').
496
496
  - `--help <boolean>` _Defaults to False._
497
497
  - Show this message and exit.
498
498
 
@@ -565,7 +565,7 @@ platform-helper pipeline generate [--terraform-platform-modules-version <terrafo
565
565
  - Override the default version of terraform-platform-modules with a specific version or branch.
566
566
  Precedence of version used is version supplied via CLI, then the version found in
567
567
  platform-config.yml/default_versions/terraform-platform-modules.
568
- In absence of these inputs, defaults to version '5'.
568
+ In absence of these inputs, defaults to version '7'.
569
569
  - `--deploy-branch <text>`
570
570
  - Specify the branch of <application>-deploy used to configure the source stage in the environment-pipeline resource.
571
571
  This is generated from the terraform/environments-pipeline/<aws_account>/main.tf file.
@@ -667,7 +667,7 @@ platform-helper notify (environment-progress|add-comment)
667
667
 
668
668
  [↩ Parent](#platform-helper-notify)
669
669
 
670
- Send environment progress notifications
670
+ Send environment progress notifications. This creates (or updates if --slack-ref is provided) the top level message to the channel.
671
671
 
672
672
  ## Usage
673
673
 
@@ -695,7 +695,7 @@ platform-helper notify environment-progress <slack_channel_id> <slack_token>
695
695
  - `--commit-sha <text>`
696
696
 
697
697
  - `--slack-ref <text>`
698
- - Slack message reference
698
+ - Slack message reference of the message to update
699
699
  - `--help <boolean>` _Defaults to False._
700
700
  - Show this message and exit.
701
701
 
@@ -703,7 +703,7 @@ platform-helper notify environment-progress <slack_channel_id> <slack_token>
703
703
 
704
704
  [↩ Parent](#platform-helper-notify)
705
705
 
706
- Add comment to a notification
706
+ Add a comment to an existing Slack message
707
707
 
708
708
  ## Usage
709
709
 
@@ -44,7 +44,7 @@ def list(app, with_images):
44
44
  @click.option("--app", help="AWS application name", required=True)
45
45
  @click.option(
46
46
  "--codebase",
47
- help="The codebase name as specified in the platform-config.yml file",
47
+ help="The codebase name as specified in the platform-config.yml file. This must be run from your codebase repository directory.",
48
48
  required=True,
49
49
  )
50
50
  @click.option("--commit", help="GitHub commit hash", required=True)
@@ -61,7 +61,7 @@ def build(app, codebase, commit):
61
61
  @click.option("--env", help="AWS Copilot environment", required=True)
62
62
  @click.option(
63
63
  "--codebase",
64
- help="The codebase name as specified in the platform-config.yml file",
64
+ help="The codebase name as specified in the platform-config.yml file. This can be run from any directory.",
65
65
  required=True,
66
66
  )
67
67
  @click.option("--commit", help="GitHub commit hash", required=True)
@@ -14,14 +14,16 @@ def notify():
14
14
  check_platform_helper_version_needs_update()
15
15
 
16
16
 
17
- @notify.command(help="Send environment progress notifications")
17
+ @notify.command(
18
+ help="Send environment progress notifications. This creates (or updates if --slack-ref is provided) the top level message to the channel."
19
+ )
18
20
  @click.argument("slack-channel-id")
19
21
  @click.argument("slack-token")
20
22
  @click.argument("message")
21
23
  @click.option("--build-arn")
22
24
  @click.option("--repository")
23
25
  @click.option("--commit-sha")
24
- @click.option("--slack-ref", help="Slack message reference")
26
+ @click.option("--slack-ref", help="Slack message reference of the message to update")
25
27
  def environment_progress(
26
28
  slack_channel_id: str,
27
29
  slack_token: str,
@@ -83,7 +85,7 @@ def _get_slack_client(token: str):
83
85
  return WebClient(token=token)
84
86
 
85
87
 
86
- @notify.command(help="Add comment to a notification")
88
+ @notify.command(help="Add a comment to an existing Slack message")
87
89
  @click.argument("slack-channel-id")
88
90
  @click.argument("slack-token")
89
91
  @click.argument("slack-ref")
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env python
2
-
3
2
  import click
4
3
 
5
4
  from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
6
5
  from dbt_platform_helper.domain.config_validator import ConfigValidator
7
6
  from dbt_platform_helper.domain.pipelines import Pipelines
8
7
  from dbt_platform_helper.providers.config import ConfigProvider
8
+ from dbt_platform_helper.providers.ecr import ECRProvider
9
+ from dbt_platform_helper.providers.io import ClickIOProvider
10
+ from dbt_platform_helper.providers.terraform_manifest import TerraformManifestProvider
9
11
  from dbt_platform_helper.utils.aws import get_codestar_connection_arn
10
12
  from dbt_platform_helper.utils.click import ClickDocOptGroup
11
13
  from dbt_platform_helper.utils.git import git_remote
@@ -36,7 +38,7 @@ def pipeline():
36
38
  <application>-deploy/platform-config.yml/environment_pipelines/<environment-pipeline>/branch).""",
37
39
  default=None,
38
40
  )
39
- def generate(terraform_platform_modules_version, deploy_branch):
41
+ def generate(terraform_platform_modules_version: str, deploy_branch: str):
40
42
  """
41
43
  Given a platform-config.yml file, generate environment and service
42
44
  deployment pipelines.
@@ -49,9 +51,16 @@ def generate(terraform_platform_modules_version, deploy_branch):
49
51
  This command does the following in relation to the codebase pipelines:
50
52
  - Generates the copilot pipeline manifest.yml for copilot/pipelines/<codebase_pipeline_name>
51
53
  """
52
- pipelines = Pipelines(
53
- ConfigProvider(ConfigValidator()),
54
- git_remote,
55
- get_codestar_connection_arn,
56
- )
57
- pipelines.generate(terraform_platform_modules_version, deploy_branch)
54
+ io = ClickIOProvider()
55
+ try:
56
+ pipelines = Pipelines(
57
+ ConfigProvider(ConfigValidator()),
58
+ TerraformManifestProvider(),
59
+ ECRProvider(),
60
+ git_remote,
61
+ get_codestar_connection_arn,
62
+ io,
63
+ )
64
+ pipelines.generate(terraform_platform_modules_version, deploy_branch)
65
+ except Exception as exc:
66
+ io.abort_with_error(str(exc))
@@ -3,7 +3,9 @@ PLATFORM_CONFIG_FILE = "platform-config.yml"
3
3
  # Todo: Can we get rid of this yet?
4
4
  PLATFORM_HELPER_VERSION_FILE = ".platform-helper-version"
5
5
  # Todo: Move to ???
6
- DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION = "5"
6
+ DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION = "7"
7
+ SUPPORTED_TERRAFORM_VERSION = "~> 1.8"
8
+ SUPPORTED_AWS_PROVIDER_VERSION = "~> 5"
7
9
 
8
10
  # Keys
9
11
  CODEBASE_PIPELINES_KEY = "codebase_pipelines"
@@ -14,12 +14,13 @@ from dbt_platform_helper.providers.io import ClickIOProvider
14
14
  from dbt_platform_helper.utils.application import Application
15
15
  from dbt_platform_helper.utils.application import ApplicationException
16
16
  from dbt_platform_helper.utils.application import load_application
17
- from dbt_platform_helper.utils.aws import check_codebase_exists
18
17
  from dbt_platform_helper.utils.aws import check_image_exists
19
18
  from dbt_platform_helper.utils.aws import get_aws_session_or_abort
20
19
  from dbt_platform_helper.utils.aws import get_build_url_from_arn
20
+ from dbt_platform_helper.utils.aws import get_build_url_from_pipeline_execution_id
21
21
  from dbt_platform_helper.utils.aws import list_latest_images
22
22
  from dbt_platform_helper.utils.aws import start_build_extraction
23
+ from dbt_platform_helper.utils.aws import start_pipeline_and_return_execution_id
23
24
  from dbt_platform_helper.utils.git import check_if_commit_exists
24
25
  from dbt_platform_helper.utils.template import setup_templates
25
26
 
@@ -30,22 +31,28 @@ class Codebase:
30
31
  io: ClickIOProvider = ClickIOProvider(),
31
32
  load_application: Callable[[str], Application] = load_application,
32
33
  get_aws_session_or_abort: Callable[[str], Session] = get_aws_session_or_abort,
33
- check_codebase_exists: Callable[[str], str] = check_codebase_exists,
34
34
  check_image_exists: Callable[[str], str] = check_image_exists,
35
35
  get_build_url_from_arn: Callable[[str], str] = get_build_url_from_arn,
36
+ get_build_url_from_pipeline_execution_id: Callable[
37
+ [str], str
38
+ ] = get_build_url_from_pipeline_execution_id,
36
39
  list_latest_images: Callable[[str], str] = list_latest_images,
37
40
  start_build_extraction: Callable[[str], str] = start_build_extraction,
41
+ start_pipeline_and_return_execution_id: Callable[
42
+ [str], str
43
+ ] = start_pipeline_and_return_execution_id,
38
44
  check_if_commit_exists: Callable[[str], str] = check_if_commit_exists,
39
45
  run_subprocess: Callable[[str], str] = subprocess.run,
40
46
  ):
41
47
  self.io = io
42
48
  self.load_application = load_application
43
49
  self.get_aws_session_or_abort = get_aws_session_or_abort
44
- self.check_codebase_exists = check_codebase_exists
45
50
  self.check_image_exists = check_image_exists
46
51
  self.get_build_url_from_arn = get_build_url_from_arn
52
+ self.get_build_url_from_pipeline_execution_id = get_build_url_from_pipeline_execution_id
47
53
  self.list_latest_images = list_latest_images
48
54
  self.start_build_extraction = start_build_extraction
55
+ self.start_pipeline_and_return_execution_id = start_pipeline_and_return_execution_id
49
56
  self.check_if_commit_exists = check_if_commit_exists
50
57
  self.run_subprocess = run_subprocess
51
58
 
@@ -122,7 +129,7 @@ class Codebase:
122
129
  self.get_build_url_from_arn,
123
130
  f'You are about to build "{app}" for "{codebase}" with commit "{commit}". Do you want to continue?',
124
131
  {
125
- "projectName": f"codebuild-{app}-{codebase}",
132
+ "projectName": f"{app}-{codebase}-codebase-pipeline-image-build",
126
133
  "artifactsOverride": {"type": "NO_ARTIFACTS"},
127
134
  "sourceVersion": commit,
128
135
  },
@@ -143,21 +150,19 @@ class Codebase:
143
150
  if not application.environments.get(env):
144
151
  raise ApplicationEnvironmentNotFoundException(env)
145
152
 
146
- self.check_codebase_exists(session, application, codebase)
147
-
148
153
  self.check_image_exists(session, application, codebase, commit)
149
154
 
150
- codebuild_client = session.client("codebuild")
151
- build_url = self.__start_build_with_confirmation(
152
- codebuild_client,
153
- self.get_build_url_from_arn,
154
- f'You are about to deploy "{app}" for "{codebase}" with commit "{commit}" to the "{env}" environment. Do you want to continue?',
155
+ pipeline_name = f"{app}-{codebase}-manual-release-pipeline"
156
+ codepipeline_client = session.client("codepipeline")
157
+
158
+ build_url = self.__start_pipeline_execution_with_confirmation(
159
+ codepipeline_client,
160
+ self.get_build_url_from_pipeline_execution_id,
161
+ f'You are about to deploy "{app}" for "{codebase}" with commit "{commit}" to the "{env}" environment using the "{pipeline_name}" deployment pipeline. Do you want to continue?',
155
162
  {
156
- "projectName": f"pipeline-{application.name}-{codebase}-BuildProject",
157
- "artifactsOverride": {"type": "NO_ARTIFACTS"},
158
- "sourceTypeOverride": "NO_SOURCE",
159
- "environmentVariablesOverride": [
160
- {"name": "COPILOT_ENVIRONMENT", "value": env},
163
+ "name": pipeline_name,
164
+ "variables": [
165
+ {"name": "ENVIRONMENT", "value": env},
161
166
  {"name": "IMAGE_TAG", "value": f"commit-{commit}"},
162
167
  ],
163
168
  },
@@ -217,6 +222,20 @@ class Codebase:
217
222
  return get_build_url_from_arn(build_arn)
218
223
  return None
219
224
 
225
+ def __start_pipeline_execution_with_confirmation(
226
+ self,
227
+ codepipeline_client,
228
+ get_build_url_from_pipeline_execution_id,
229
+ confirmation_message,
230
+ build_options,
231
+ ):
232
+ if self.io.confirm(confirmation_message):
233
+ execution_id = self.start_pipeline_and_return_execution_id(
234
+ codepipeline_client, build_options
235
+ )
236
+ return get_build_url_from_pipeline_execution_id(execution_id, build_options["name"])
237
+ return None
238
+
220
239
 
221
240
  class ApplicationDeploymentNotTriggered(PlatformException):
222
241
  def __init__(self, codebase: str):
@@ -2,13 +2,9 @@ from typing import Callable
2
2
 
3
3
  import boto3
4
4
 
5
- from dbt_platform_helper.constants import CODEBASE_PIPELINES_KEY
6
- from dbt_platform_helper.constants import ENVIRONMENTS_KEY
7
- from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
8
5
  from dbt_platform_helper.providers.io import ClickIOProvider
9
6
  from dbt_platform_helper.providers.opensearch import OpensearchProvider
10
7
  from dbt_platform_helper.providers.redis import RedisProvider
11
- from dbt_platform_helper.utils.messages import abort_with_error
12
8
 
13
9
 
14
10
  class ConfigValidator:
@@ -20,7 +16,6 @@ class ConfigValidator:
20
16
  self.validate_supported_redis_versions,
21
17
  self.validate_supported_opensearch_versions,
22
18
  self.validate_environment_pipelines,
23
- self.validate_codebase_pipelines,
24
19
  self.validate_environment_pipelines_triggers,
25
20
  self.validate_database_copy_section,
26
21
  self.validate_database_migration_input_sources,
@@ -115,23 +110,7 @@ class ConfigValidator:
115
110
  envs = detail["bad_envs"]
116
111
  acc = detail["account"]
117
112
  message += f" '{pipeline}' - these environments are not in the '{acc}' account: {', '.join(envs)}\n"
118
- abort_with_error(message)
119
-
120
- def validate_codebase_pipelines(self, config):
121
- if CODEBASE_PIPELINES_KEY in config:
122
- for codebase in config[CODEBASE_PIPELINES_KEY]:
123
- codebase_environments = []
124
-
125
- for pipeline in codebase["pipelines"]:
126
- codebase_environments += [e["name"] for e in pipeline[ENVIRONMENTS_KEY]]
127
-
128
- unique_codebase_environments = sorted(list(set(codebase_environments)))
129
-
130
- if sorted(codebase_environments) != sorted(unique_codebase_environments):
131
- abort_with_error(
132
- f"The {PLATFORM_CONFIG_FILE} file is invalid, each environment can only be "
133
- "listed in a single pipeline per codebase"
134
- )
113
+ self.io.abort_with_error(message)
135
114
 
136
115
  def validate_environment_pipelines_triggers(self, config):
137
116
  errors = []
@@ -155,7 +134,7 @@ class ConfigValidator:
155
134
 
156
135
  if errors:
157
136
  error_message = "The following pipelines are misconfigured: \n"
158
- abort_with_error(error_message + "\n ".join(errors))
137
+ self.io.abort_with_error(error_message + "\n ".join(errors))
159
138
 
160
139
  def validate_database_copy_section(self, config):
161
140
  extensions = config.get("extensions", {})
@@ -241,9 +220,9 @@ class ConfigValidator:
241
220
  )
242
221
 
243
222
  if errors:
244
- abort_with_error("\n".join(errors))
223
+ self.io.abort_with_error("\n".join(errors))
245
224
 
246
- def validate_database_migration_input_sources(self, config):
225
+ def validate_database_migration_input_sources(self, config: dict):
247
226
  extensions = config.get("extensions", {})
248
227
  if not extensions:
249
228
  return
@@ -270,6 +249,5 @@ class ConfigValidator:
270
249
  errors.append(
271
250
  f"Error in '{extension_name}.environments.{env}.data_migration': 'import_sources' property is missing."
272
251
  )
273
-
274
252
  if errors:
275
- abort_with_error("\n".join(errors))
253
+ self.io.abort_with_error("\n".join(errors))
@@ -2,6 +2,7 @@ import itertools
2
2
  import random
3
3
  import re
4
4
  import string
5
+ import traceback
5
6
  from pathlib import Path
6
7
  from typing import Callable
7
8
  from typing import List
@@ -28,10 +29,32 @@ class MaintenancePageException(PlatformException):
28
29
 
29
30
 
30
31
  class LoadBalancedWebServiceNotFoundException(MaintenancePageException):
31
- def __init__(self, application_name):
32
+ def __init__(self, application_name: str):
32
33
  super().__init__(f"No services deployed yet to {application_name} ")
33
34
 
34
35
 
36
+ class FailedToActivateMaintenancePageException(MaintenancePageException):
37
+ def __init__(
38
+ self,
39
+ application_name: str,
40
+ env: str,
41
+ original_exception: Exception,
42
+ rolled_back_rules: dict[str, bool] = {},
43
+ ):
44
+ super().__init__(
45
+ f"Maintenance page failed to activate for the {application_name} application in environment {env}."
46
+ )
47
+ self.orginal_exception = original_exception
48
+ self.rolled_back_rules = rolled_back_rules
49
+
50
+ def __str__(self):
51
+ return (
52
+ f"{super().__str__()}\n"
53
+ f"Rolled-back rules: {self.rolled_back_rules }\n"
54
+ f"Original exception: {self.orginal_exception}"
55
+ )
56
+
57
+
35
58
  def get_maintenance_page_type(session: boto3.Session, listener_arn: str) -> Union[str, None]:
36
59
  lb_client = session.client("elbv2")
37
60
 
@@ -75,85 +98,99 @@ def add_maintenance_page(
75
98
  bypass_value = "".join(random.choices(string.ascii_lowercase + string.digits, k=12))
76
99
 
77
100
  rule_priority = itertools.count(start=1)
101
+ try:
102
+ for svc in services:
103
+ target_group_arn = find_target_group(app, env, svc.name, session)
104
+
105
+ # not all of an application's services are guaranteed to have been deployed to an environment
106
+ if not target_group_arn:
107
+ continue
108
+
109
+ for ip in allowed_ips:
110
+ create_header_rule(
111
+ lb_client,
112
+ listener_arn,
113
+ target_group_arn,
114
+ "X-Forwarded-For",
115
+ [ip],
116
+ "AllowedIps",
117
+ next(rule_priority),
118
+ )
119
+ create_source_ip_rule(
120
+ lb_client,
121
+ listener_arn,
122
+ target_group_arn,
123
+ [ip],
124
+ "AllowedSourceIps",
125
+ next(rule_priority),
126
+ )
78
127
 
79
- for svc in services:
80
- target_group_arn = find_target_group(app, env, svc.name, session)
81
-
82
- # not all of an application's services are guaranteed to have been deployed to an environment
83
- if not target_group_arn:
84
- continue
85
-
86
- for ip in allowed_ips:
87
128
  create_header_rule(
88
129
  lb_client,
89
130
  listener_arn,
90
131
  target_group_arn,
91
- "X-Forwarded-For",
92
- [ip],
93
- "AllowedIps",
132
+ "Bypass-Key",
133
+ [bypass_value],
134
+ "BypassIpFilter",
94
135
  next(rule_priority),
95
136
  )
96
- create_source_ip_rule(
97
- lb_client,
98
- listener_arn,
99
- target_group_arn,
100
- [ip],
101
- "AllowedSourceIps",
102
- next(rule_priority),
103
- )
104
-
105
- create_header_rule(
106
- lb_client,
107
- listener_arn,
108
- target_group_arn,
109
- "Bypass-Key",
110
- [bypass_value],
111
- "BypassIpFilter",
112
- next(rule_priority),
113
- )
114
137
 
115
138
  click.secho(
116
139
  f"\nUse a browser plugin to add `Bypass-Key` header with value {bypass_value} to your requests. For more detail, visit https://platform.readme.trade.gov.uk/next-steps/put-a-service-under-maintenance/",
117
140
  )
118
141
 
119
- lb_client.create_rule(
120
- ListenerArn=listener_arn,
121
- Priority=next(rule_priority),
122
- Conditions=[
123
- {
124
- "Field": "path-pattern",
125
- "PathPatternConfig": {"Values": ["/*"]},
126
- }
127
- ],
128
- Actions=[
129
- {
130
- "Type": "fixed-response",
131
- "FixedResponseConfig": {
132
- "StatusCode": "503",
133
- "ContentType": "text/html",
134
- "MessageBody": maintenance_page_content,
135
- },
136
- }
137
- ],
138
- Tags=[
139
- {"Key": "name", "Value": "MaintenancePage"},
140
- {"Key": "type", "Value": template},
141
- ],
142
- )
142
+ lb_client.create_rule(
143
+ ListenerArn=listener_arn,
144
+ Priority=next(rule_priority),
145
+ Conditions=[
146
+ {
147
+ "Field": "path-pattern",
148
+ "PathPatternConfig": {"Values": ["/*"]},
149
+ }
150
+ ],
151
+ Actions=[
152
+ {
153
+ "Type": "fixed-response",
154
+ "FixedResponseConfig": {
155
+ "StatusCode": "503",
156
+ "ContentType": "text/html",
157
+ "MessageBody": maintenance_page_content,
158
+ },
159
+ }
160
+ ],
161
+ Tags=[
162
+ {"Key": "name", "Value": "MaintenancePage"},
163
+ {"Key": "type", "Value": template},
164
+ ],
165
+ )
166
+ except Exception as e:
167
+ deleted_rules = clean_up_maintenance_page_rules(session, listener_arn)
168
+ raise FailedToActivateMaintenancePageException(
169
+ app, env, f"{e}:\n {traceback.format_exc()}", deleted_rules
170
+ )
143
171
 
144
172
 
145
- def remove_maintenance_page(session: boto3.Session, listener_arn: str):
173
+ def clean_up_maintenance_page_rules(
174
+ session: boto3.Session, listener_arn: str, fail_when_not_deleted: bool = False
175
+ ) -> dict[str, bool]:
146
176
  lb_client = session.client("elbv2")
147
177
 
148
178
  rules = lb_client.describe_rules(ListenerArn=listener_arn)["Rules"]
149
179
  tag_descriptions = get_rules_tag_descriptions(rules, lb_client)
150
180
 
181
+ deletes = {}
151
182
  for name in ["MaintenancePage", "AllowedIps", "BypassIpFilter", "AllowedSourceIps"]:
152
183
  deleted = delete_listener_rule(tag_descriptions, name, lb_client)
153
-
154
- if name == "MaintenancePage" and not deleted:
184
+ deletes[name] = bool(deleted)
185
+ if fail_when_not_deleted and name == "MaintenancePage" and not deleted:
155
186
  raise ListenerRuleNotFoundException()
156
187
 
188
+ return deletes
189
+
190
+
191
+ def remove_maintenance_page(session: boto3.Session, listener_arn: str):
192
+ clean_up_maintenance_page_rules(session, listener_arn, True)
193
+
157
194
 
158
195
  class MaintenancePage:
159
196
  def __init__(