dbt-platform-helper 11.0.1__tar.gz → 11.1.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.
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/PKG-INFO +2 -1
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/COMMANDS.md +60 -19
- dbt_platform_helper-11.1.0/dbt_platform_helper/commands/database.py +112 -0
- dbt_platform_helper-11.1.0/dbt_platform_helper/commands/environment.py +218 -0
- dbt_platform_helper-11.1.0/dbt_platform_helper/domain/database_copy.py +220 -0
- dbt_platform_helper-11.1.0/dbt_platform_helper/domain/maintenance_page.py +459 -0
- dbt_platform_helper-11.1.0/dbt_platform_helper/providers/load_balancers.py +51 -0
- dbt_platform_helper-11.1.0/dbt_platform_helper/utils/__init__.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/aws.py +47 -37
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/validation.py +29 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/pyproject.toml +2 -1
- dbt_platform_helper-11.0.1/dbt_platform_helper/commands/database.py +0 -33
- dbt_platform_helper-11.0.1/dbt_platform_helper/commands/database_helpers.py +0 -145
- dbt_platform_helper-11.0.1/dbt_platform_helper/commands/environment.py +0 -730
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/LICENSE +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/README.md +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/__init__.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/addon-plans.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/addons-template-map.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/__init__.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/application.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/check_cloudformation.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/codebase.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/conduit.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/config.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/copilot.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/dns.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/generate.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/notify.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/pipeline.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/secrets.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/commands/version.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/constants.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/custom_resources/__init__.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/custom_resources/s3_object.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/default-extensions.yml +0 -0
- {dbt_platform_helper-11.0.1/dbt_platform_helper/utils → dbt_platform_helper-11.1.0/dbt_platform_helper/domain}/__init__.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/exceptions.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/jinja2_tags.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/config.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/image_build_run.sh +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/phases/build.sh +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/phases/install.sh +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/phases/post_build.sh +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/.copilot/phases/pre_build.sh +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/COMMANDS.md.jinja +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addon-instructions.txt +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/README.md +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/addons.parameters.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/aurora-postgres.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/monitoring.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/opensearch.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/rds-postgres.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/redis-cluster.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/s3.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/env/vpc.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/svc/prometheus-policy.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/svc/s3-policy.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/addons/svc/subscription-filter.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/ci-codebuild-role-policy.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/create-codebuild-role.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/custom-codebuild-role-policy.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/manifest.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/.gitignore +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/README.md +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/bin/override.ts +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/cdk.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/log_resource_policy.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/package-lock.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/package.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/stack.ts +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/overrides/tsconfig.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/env/terraform-overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/environments/main.tf +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/manifest.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/.gitignore +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/bin/override.ts +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.deploy.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.image.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/cdk.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/package-lock.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/package.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/stack.ts +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/tsconfig.json +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/codebase/overrides/types.ts +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/environments/buildspec.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/environments/manifest.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/pipelines/environments/overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/maintenance_pages/default.html +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/maintenance_pages/dmas-migration.html +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/maintenance_pages/migration.html +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/manifest-backend.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/manifest-public.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/templates/svc/overrides/cfn.patches.yml +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/application.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/arn_parser.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/click.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/cloudformation.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/cloudfoundry.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/files.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/git.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/manifests.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/messages.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/platform_config.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/template.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/dbt_platform_helper/utils/versioning.py +0 -0
- {dbt_platform_helper-11.0.1 → dbt_platform_helper-11.1.0}/platform_helper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dbt-platform-helper
|
|
3
|
-
Version: 11.0
|
|
3
|
+
Version: 11.1.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
|
|
@@ -34,6 +34,7 @@ Requires-Dist: schema (==0.7.5)
|
|
|
34
34
|
Requires-Dist: semver (>=3.0.2,<4.0.0)
|
|
35
35
|
Requires-Dist: slack-sdk (>=3.27.1,<4.0.0)
|
|
36
36
|
Requires-Dist: tomlkit (>=0.12.2,<0.13.0)
|
|
37
|
+
Requires-Dist: yamllint (>=1.35.1,<2.0.0)
|
|
37
38
|
Description-Content-Type: text/markdown
|
|
38
39
|
|
|
39
40
|
# DBT Platform Helper
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
- [platform-helper database](#platform-helper-database)
|
|
43
43
|
- [platform-helper database dump](#platform-helper-database-dump)
|
|
44
44
|
- [platform-helper database load](#platform-helper-database-load)
|
|
45
|
+
- [platform-helper database copy](#platform-helper-database-copy)
|
|
45
46
|
- [platform-helper version](#platform-helper-version)
|
|
46
47
|
- [platform-helper version get-platform-helper-for-project](#platform-helper-version-get-platform-helper-for-project)
|
|
47
48
|
|
|
@@ -962,10 +963,12 @@ platform-helper notify add-comment <slack_channel_id> <slack_token>
|
|
|
962
963
|
|
|
963
964
|
[↩ Parent](#platform-helper)
|
|
964
965
|
|
|
966
|
+
Commands to copy data between databases.
|
|
967
|
+
|
|
965
968
|
## Usage
|
|
966
969
|
|
|
967
970
|
```
|
|
968
|
-
platform-helper database (dump|load)
|
|
971
|
+
platform-helper database (dump|load|copy)
|
|
969
972
|
```
|
|
970
973
|
|
|
971
974
|
## Options
|
|
@@ -975,6 +978,7 @@ platform-helper database (dump|load)
|
|
|
975
978
|
|
|
976
979
|
## Commands
|
|
977
980
|
|
|
981
|
+
- [`copy` ↪](#platform-helper-database-copy)
|
|
978
982
|
- [`dump` ↪](#platform-helper-database-dump)
|
|
979
983
|
- [`load` ↪](#platform-helper-database-load)
|
|
980
984
|
|
|
@@ -987,23 +991,20 @@ platform-helper database (dump|load)
|
|
|
987
991
|
## Usage
|
|
988
992
|
|
|
989
993
|
```
|
|
990
|
-
platform-helper database dump --
|
|
991
|
-
--
|
|
992
|
-
--vpc-name <vpc_name>
|
|
994
|
+
platform-helper database dump --from <from_env> --database <database>
|
|
995
|
+
[--app <application>] [--from-vpc <from_vpc>]
|
|
993
996
|
```
|
|
994
997
|
|
|
995
998
|
## Options
|
|
996
999
|
|
|
997
|
-
- `--account-id <text>`
|
|
998
|
-
|
|
999
1000
|
- `--app <text>`
|
|
1000
|
-
|
|
1001
|
-
- `--
|
|
1002
|
-
|
|
1001
|
+
- The application name. Required unless you are running the command from your deploy repo
|
|
1002
|
+
- `--from <text>`
|
|
1003
|
+
- The environment you are dumping data from
|
|
1003
1004
|
- `--database <text>`
|
|
1004
|
-
|
|
1005
|
-
- `--vpc
|
|
1006
|
-
|
|
1005
|
+
- The name of the database you are dumping data from
|
|
1006
|
+
- `--from-vpc <text>`
|
|
1007
|
+
- The vpc the specified environment is running in. Required unless you are running the command from your deploy repo
|
|
1007
1008
|
- `--help <boolean>` _Defaults to False._
|
|
1008
1009
|
- Show this message and exit.
|
|
1009
1010
|
|
|
@@ -1016,22 +1017,62 @@ platform-helper database dump --account-id <account_id> --app <application>
|
|
|
1016
1017
|
## Usage
|
|
1017
1018
|
|
|
1018
1019
|
```
|
|
1019
|
-
platform-helper database load --
|
|
1020
|
-
--
|
|
1021
|
-
--
|
|
1020
|
+
platform-helper database load --to <to_env> --database <database>
|
|
1021
|
+
[--app <application>] [--to-vpc <to_vpc>]
|
|
1022
|
+
[--auto-approve]
|
|
1022
1023
|
```
|
|
1023
1024
|
|
|
1024
1025
|
## Options
|
|
1025
1026
|
|
|
1026
|
-
- `--account-id <text>`
|
|
1027
|
-
|
|
1028
1027
|
- `--app <text>`
|
|
1028
|
+
- The application name. Required unless you are running the command from your deploy repo
|
|
1029
|
+
- `--to <text>`
|
|
1030
|
+
- The environment you are loading data into
|
|
1031
|
+
- `--database <text>`
|
|
1032
|
+
- The name of the database you are loading data into
|
|
1033
|
+
- `--to-vpc <text>`
|
|
1034
|
+
- The vpc the specified environment is running in. Required unless you are running the command from your deploy repo
|
|
1035
|
+
- `--auto-approve <boolean>` _Defaults to False._
|
|
1029
1036
|
|
|
1030
|
-
- `--
|
|
1037
|
+
- `--help <boolean>` _Defaults to False._
|
|
1038
|
+
- Show this message and exit.
|
|
1039
|
+
|
|
1040
|
+
# platform-helper database copy
|
|
1041
|
+
|
|
1042
|
+
[↩ Parent](#platform-helper-database)
|
|
1043
|
+
|
|
1044
|
+
Copy a database between environments.
|
|
1045
|
+
|
|
1046
|
+
## Usage
|
|
1031
1047
|
|
|
1048
|
+
```
|
|
1049
|
+
platform-helper database copy --from <from_env> --to <to_env> --database <database>
|
|
1050
|
+
--svc <service> [--app <application>] [--from-vpc <from_vpc>]
|
|
1051
|
+
[--to-vpc <to_vpc>] [--template (default|migration|dmas-migration)]
|
|
1052
|
+
[--auto-approve] [--no-maintenance-page]
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
## Options
|
|
1056
|
+
|
|
1057
|
+
- `--app <text>`
|
|
1058
|
+
- The application name. Required unless you are running the command from your deploy repo
|
|
1059
|
+
- `--from <text>`
|
|
1060
|
+
- The environment you are copying data from
|
|
1061
|
+
- `--to <text>`
|
|
1062
|
+
- The environment you are copying data into
|
|
1032
1063
|
- `--database <text>`
|
|
1064
|
+
- The name of the database you are copying
|
|
1065
|
+
- `--from-vpc <text>`
|
|
1066
|
+
- The vpc the environment you are copying from is running in. Required unless you are running the command from your deploy repo
|
|
1067
|
+
- `--to-vpc <text>`
|
|
1068
|
+
- The vpc the environment you are copying into is running in. Required unless you are running the command from your deploy repo
|
|
1069
|
+
- `--auto-approve <boolean>` _Defaults to False._
|
|
1033
1070
|
|
|
1034
|
-
- `--
|
|
1071
|
+
- `--svc <text>` _Defaults to ['web']._
|
|
1072
|
+
|
|
1073
|
+
- `--template <choice>` _Defaults to default._
|
|
1074
|
+
- The maintenance page you wish to put up.
|
|
1075
|
+
- `--no-maintenance-page <boolean>` _Defaults to False._
|
|
1035
1076
|
|
|
1036
1077
|
- `--help <boolean>` _Defaults to False._
|
|
1037
1078
|
- Show this message and exit.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from dbt_platform_helper.commands.environment import AVAILABLE_TEMPLATES
|
|
4
|
+
from dbt_platform_helper.domain.database_copy import DatabaseCopy
|
|
5
|
+
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group(chain=True, cls=ClickDocOptGroup)
|
|
9
|
+
def database():
|
|
10
|
+
"""Commands to copy data between databases."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@database.command(name="dump")
|
|
14
|
+
@click.option(
|
|
15
|
+
"--app",
|
|
16
|
+
type=str,
|
|
17
|
+
help="The application name. Required unless you are running the command from your deploy repo",
|
|
18
|
+
)
|
|
19
|
+
@click.option(
|
|
20
|
+
"--from",
|
|
21
|
+
"from_env",
|
|
22
|
+
type=str,
|
|
23
|
+
required=True,
|
|
24
|
+
help="The environment you are dumping data from",
|
|
25
|
+
)
|
|
26
|
+
@click.option(
|
|
27
|
+
"--database", type=str, required=True, help="The name of the database you are dumping data from"
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--from-vpc",
|
|
31
|
+
type=str,
|
|
32
|
+
help="The vpc the specified environment is running in. Required unless you are running the command from your deploy repo",
|
|
33
|
+
)
|
|
34
|
+
def dump(app, from_env, database, from_vpc):
|
|
35
|
+
"""Dump a database into an S3 bucket."""
|
|
36
|
+
data_copy = DatabaseCopy(app, database)
|
|
37
|
+
data_copy.dump(from_env, from_vpc)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@database.command(name="load")
|
|
41
|
+
@click.option(
|
|
42
|
+
"--app",
|
|
43
|
+
type=str,
|
|
44
|
+
help="The application name. Required unless you are running the command from your deploy repo",
|
|
45
|
+
)
|
|
46
|
+
@click.option(
|
|
47
|
+
"--to", "to_env", type=str, required=True, help="The environment you are loading data into"
|
|
48
|
+
)
|
|
49
|
+
@click.option(
|
|
50
|
+
"--database", type=str, required=True, help="The name of the database you are loading data into"
|
|
51
|
+
)
|
|
52
|
+
@click.option(
|
|
53
|
+
"--to-vpc",
|
|
54
|
+
type=str,
|
|
55
|
+
help="The vpc the specified environment is running in. Required unless you are running the command from your deploy repo",
|
|
56
|
+
)
|
|
57
|
+
@click.option("--auto-approve/--no-auto-approve", default=False)
|
|
58
|
+
def load(app, to_env, database, to_vpc, auto_approve):
|
|
59
|
+
"""Load a database from an S3 bucket."""
|
|
60
|
+
data_copy = DatabaseCopy(app, database, auto_approve)
|
|
61
|
+
data_copy.load(to_env, to_vpc)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@database.command(name="copy")
|
|
65
|
+
@click.option(
|
|
66
|
+
"--app",
|
|
67
|
+
type=str,
|
|
68
|
+
help="The application name. Required unless you are running the command from your deploy repo",
|
|
69
|
+
)
|
|
70
|
+
@click.option(
|
|
71
|
+
"--from", "from_env", type=str, required=True, help="The environment you are copying data from"
|
|
72
|
+
)
|
|
73
|
+
@click.option(
|
|
74
|
+
"--to", "to_env", type=str, required=True, help="The environment you are copying data into"
|
|
75
|
+
)
|
|
76
|
+
@click.option(
|
|
77
|
+
"--database", type=str, required=True, help="The name of the database you are copying"
|
|
78
|
+
)
|
|
79
|
+
@click.option(
|
|
80
|
+
"--from-vpc",
|
|
81
|
+
type=str,
|
|
82
|
+
help="The vpc the environment you are copying from is running in. Required unless you are running the command from your deploy repo",
|
|
83
|
+
)
|
|
84
|
+
@click.option(
|
|
85
|
+
"--to-vpc",
|
|
86
|
+
type=str,
|
|
87
|
+
help="The vpc the environment you are copying into is running in. Required unless you are running the command from your deploy repo",
|
|
88
|
+
)
|
|
89
|
+
@click.option("--auto-approve/--no-auto-approve", default=False)
|
|
90
|
+
@click.option("--svc", type=str, required=True, multiple=True, default=["web"])
|
|
91
|
+
@click.option(
|
|
92
|
+
"--template",
|
|
93
|
+
type=click.Choice(AVAILABLE_TEMPLATES),
|
|
94
|
+
default="default",
|
|
95
|
+
help="The maintenance page you wish to put up.",
|
|
96
|
+
)
|
|
97
|
+
@click.option("--no-maintenance-page", flag_value=True)
|
|
98
|
+
def copy(
|
|
99
|
+
app,
|
|
100
|
+
from_env,
|
|
101
|
+
to_env,
|
|
102
|
+
database,
|
|
103
|
+
from_vpc,
|
|
104
|
+
to_vpc,
|
|
105
|
+
auto_approve,
|
|
106
|
+
svc,
|
|
107
|
+
template,
|
|
108
|
+
no_maintenance_page,
|
|
109
|
+
):
|
|
110
|
+
"""Copy a database between environments."""
|
|
111
|
+
data_copy = DatabaseCopy(app, database, auto_approve)
|
|
112
|
+
data_copy.copy(from_env, to_env, from_vpc, to_vpc, svc, template, no_maintenance_page)
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import boto3
|
|
2
|
+
import click
|
|
3
|
+
from schema import SchemaError
|
|
4
|
+
|
|
5
|
+
from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
|
|
6
|
+
from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
|
|
7
|
+
from dbt_platform_helper.domain.maintenance_page import MaintenancePageProvider
|
|
8
|
+
from dbt_platform_helper.providers.load_balancers import find_https_listener
|
|
9
|
+
from dbt_platform_helper.utils.aws import get_aws_session_or_abort
|
|
10
|
+
from dbt_platform_helper.utils.click import ClickDocOptGroup
|
|
11
|
+
from dbt_platform_helper.utils.files import apply_environment_defaults
|
|
12
|
+
from dbt_platform_helper.utils.files import mkfile
|
|
13
|
+
from dbt_platform_helper.utils.platform_config import is_terraform_project
|
|
14
|
+
from dbt_platform_helper.utils.template import setup_templates
|
|
15
|
+
from dbt_platform_helper.utils.validation import load_and_validate_platform_config
|
|
16
|
+
from dbt_platform_helper.utils.versioning import (
|
|
17
|
+
check_platform_helper_version_needs_update,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
AVAILABLE_TEMPLATES = ["default", "migration", "dmas-migration"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@click.group(cls=ClickDocOptGroup)
|
|
24
|
+
def environment():
|
|
25
|
+
"""Commands affecting environments."""
|
|
26
|
+
check_platform_helper_version_needs_update()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@environment.command()
|
|
30
|
+
@click.option("--app", type=str, required=True)
|
|
31
|
+
@click.option("--env", type=str, required=True)
|
|
32
|
+
@click.option("--svc", type=str, required=True, multiple=True, default=["web"])
|
|
33
|
+
@click.option(
|
|
34
|
+
"--template",
|
|
35
|
+
type=click.Choice(AVAILABLE_TEMPLATES),
|
|
36
|
+
default="default",
|
|
37
|
+
help="The maintenance page you wish to put up.",
|
|
38
|
+
)
|
|
39
|
+
@click.option("--vpc", type=str)
|
|
40
|
+
def offline(app, env, svc, template, vpc):
|
|
41
|
+
"""Take load-balanced web services offline with a maintenance page."""
|
|
42
|
+
maintenance_page = MaintenancePageProvider()
|
|
43
|
+
maintenance_page.activate(app, env, svc, template, vpc)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@environment.command()
|
|
47
|
+
@click.option("--app", type=str, required=True)
|
|
48
|
+
@click.option("--env", type=str, required=True)
|
|
49
|
+
def online(app, env):
|
|
50
|
+
"""Remove a maintenance page from an environment."""
|
|
51
|
+
maintenance_page = MaintenancePageProvider()
|
|
52
|
+
maintenance_page.deactivate(app, env)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_vpc_id(session, env_name, vpc_name=None):
|
|
56
|
+
if not vpc_name:
|
|
57
|
+
vpc_name = f"{session.profile_name}-{env_name}"
|
|
58
|
+
|
|
59
|
+
filters = [{"Name": "tag:Name", "Values": [vpc_name]}]
|
|
60
|
+
vpcs = session.client("ec2").describe_vpcs(Filters=filters)["Vpcs"]
|
|
61
|
+
|
|
62
|
+
if not vpcs:
|
|
63
|
+
filters[0]["Values"] = [session.profile_name]
|
|
64
|
+
vpcs = session.client("ec2").describe_vpcs(Filters=filters)["Vpcs"]
|
|
65
|
+
|
|
66
|
+
if not vpcs:
|
|
67
|
+
click.secho(
|
|
68
|
+
f"No VPC found with name {vpc_name} in AWS account {session.profile_name}.", fg="red"
|
|
69
|
+
)
|
|
70
|
+
raise click.Abort
|
|
71
|
+
|
|
72
|
+
return vpcs[0]["VpcId"]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def get_subnet_ids(session, vpc_id):
|
|
76
|
+
subnets = session.client("ec2").describe_subnets(
|
|
77
|
+
Filters=[{"Name": "vpc-id", "Values": [vpc_id]}]
|
|
78
|
+
)["Subnets"]
|
|
79
|
+
|
|
80
|
+
if not subnets:
|
|
81
|
+
click.secho(f"No subnets found for VPC with id: {vpc_id}.", fg="red")
|
|
82
|
+
raise click.Abort
|
|
83
|
+
|
|
84
|
+
public_tag = {"Key": "subnet_type", "Value": "public"}
|
|
85
|
+
public = [subnet["SubnetId"] for subnet in subnets if public_tag in subnet["Tags"]]
|
|
86
|
+
private_tag = {"Key": "subnet_type", "Value": "private"}
|
|
87
|
+
private = [subnet["SubnetId"] for subnet in subnets if private_tag in subnet["Tags"]]
|
|
88
|
+
|
|
89
|
+
return public, private
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def get_cert_arn(session, application, env_name):
|
|
93
|
+
try:
|
|
94
|
+
arn = find_https_certificate(session, application, env_name)
|
|
95
|
+
except:
|
|
96
|
+
click.secho(
|
|
97
|
+
f"No certificate found with domain name matching environment {env_name}.", fg="red"
|
|
98
|
+
)
|
|
99
|
+
raise click.Abort
|
|
100
|
+
|
|
101
|
+
return arn
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@environment.command()
|
|
105
|
+
@click.option("--vpc-name", hidden=True)
|
|
106
|
+
@click.option("--name", "-n", required=True)
|
|
107
|
+
def generate(name, vpc_name):
|
|
108
|
+
if vpc_name:
|
|
109
|
+
click.secho(
|
|
110
|
+
f"This option is deprecated. Please add the VPC name for your envs to {PLATFORM_CONFIG_FILE}",
|
|
111
|
+
fg="red",
|
|
112
|
+
)
|
|
113
|
+
raise click.Abort
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
conf = load_and_validate_platform_config()
|
|
117
|
+
except SchemaError as ex:
|
|
118
|
+
click.secho(f"Invalid `{PLATFORM_CONFIG_FILE}` file: {str(ex)}", fg="red")
|
|
119
|
+
raise click.Abort
|
|
120
|
+
|
|
121
|
+
env_config = apply_environment_defaults(conf)["environments"][name]
|
|
122
|
+
profile_for_environment = env_config.get("accounts", {}).get("deploy", {}).get("name")
|
|
123
|
+
click.secho(f"Using {profile_for_environment} for this AWS session")
|
|
124
|
+
session = get_aws_session_or_abort(profile_for_environment)
|
|
125
|
+
|
|
126
|
+
_generate_copilot_environment_manifests(name, conf["application"], env_config, session)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@environment.command(help="Generate terraform manifest for the specified environment.")
|
|
130
|
+
@click.option(
|
|
131
|
+
"--name", "-n", required=True, help="The name of the environment to generate a manifest for."
|
|
132
|
+
)
|
|
133
|
+
@click.option(
|
|
134
|
+
"--terraform-platform-modules-version",
|
|
135
|
+
help=f"Override the default version of terraform-platform-modules. (Default version is '{DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION}').",
|
|
136
|
+
)
|
|
137
|
+
def generate_terraform(name, terraform_platform_modules_version):
|
|
138
|
+
if not is_terraform_project():
|
|
139
|
+
click.secho("This is not a terraform project. Exiting.", fg="red")
|
|
140
|
+
exit(1)
|
|
141
|
+
|
|
142
|
+
conf = load_and_validate_platform_config()
|
|
143
|
+
|
|
144
|
+
env_config = apply_environment_defaults(conf)["environments"][name]
|
|
145
|
+
_generate_terraform_environment_manifests(
|
|
146
|
+
conf["application"], name, env_config, terraform_platform_modules_version
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _generate_copilot_environment_manifests(name, application, env_config, session):
|
|
151
|
+
env_template = setup_templates().get_template("env/manifest.yml")
|
|
152
|
+
vpc_name = env_config.get("vpc", None)
|
|
153
|
+
vpc_id = get_vpc_id(session, name, vpc_name)
|
|
154
|
+
pub_subnet_ids, priv_subnet_ids = get_subnet_ids(session, vpc_id)
|
|
155
|
+
cert_arn = get_cert_arn(session, application, name)
|
|
156
|
+
contents = env_template.render(
|
|
157
|
+
{
|
|
158
|
+
"name": name,
|
|
159
|
+
"vpc_id": vpc_id,
|
|
160
|
+
"pub_subnet_ids": pub_subnet_ids,
|
|
161
|
+
"priv_subnet_ids": priv_subnet_ids,
|
|
162
|
+
"certificate_arn": cert_arn,
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
click.echo(mkfile(".", f"copilot/environments/{name}/manifest.yml", contents, overwrite=True))
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _generate_terraform_environment_manifests(
|
|
169
|
+
application, env, env_config, cli_terraform_platform_modules_version
|
|
170
|
+
):
|
|
171
|
+
env_template = setup_templates().get_template("environments/main.tf")
|
|
172
|
+
|
|
173
|
+
terraform_platform_modules_version = _determine_terraform_platform_modules_version(
|
|
174
|
+
env_config, cli_terraform_platform_modules_version
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
contents = env_template.render(
|
|
178
|
+
{
|
|
179
|
+
"application": application,
|
|
180
|
+
"environment": env,
|
|
181
|
+
"config": env_config,
|
|
182
|
+
"terraform_platform_modules_version": terraform_platform_modules_version,
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
click.echo(mkfile(".", f"terraform/environments/{env}/main.tf", contents, overwrite=True))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _determine_terraform_platform_modules_version(env_conf, cli_terraform_platform_modules_version):
|
|
190
|
+
cli_terraform_platform_modules_version = cli_terraform_platform_modules_version
|
|
191
|
+
env_conf_terraform_platform_modules_version = env_conf.get("versions", {}).get(
|
|
192
|
+
"terraform-platform-modules"
|
|
193
|
+
)
|
|
194
|
+
version_preference_order = [
|
|
195
|
+
cli_terraform_platform_modules_version,
|
|
196
|
+
env_conf_terraform_platform_modules_version,
|
|
197
|
+
DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION,
|
|
198
|
+
]
|
|
199
|
+
return [version for version in version_preference_order if version][0]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def find_https_certificate(session: boto3.Session, app: str, env: str) -> str:
|
|
203
|
+
listener_arn = find_https_listener(session, app, env)
|
|
204
|
+
cert_client = session.client("elbv2")
|
|
205
|
+
certificates = cert_client.describe_listener_certificates(ListenerArn=listener_arn)[
|
|
206
|
+
"Certificates"
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
certificate_arn = next(c["CertificateArn"] for c in certificates if c["IsDefault"])
|
|
211
|
+
except StopIteration:
|
|
212
|
+
raise CertificateNotFoundError()
|
|
213
|
+
|
|
214
|
+
return certificate_arn
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class CertificateNotFoundError(Exception):
|
|
218
|
+
pass
|