generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3870 from ministryofjustice/dpl-1662-delete-table…
…-infra 🚧 Define delete table infrastructure
- Loading branch information
Showing
8 changed files
with
135 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
terraform/environments/data-platform/tests/delete_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
import boto3 | ||
import requests | ||
|
||
|
||
data_product_name = "example_prison_data_product" | ||
table_name = "testing" | ||
base_url = "https://hsolkci589.execute-api.eu-west-2.amazonaws.com/development" | ||
schema_url = f"/data-product/{data_product_name}/table/{table_name}" | ||
url = base_url + schema_url | ||
glue = boto3.client("glue") | ||
|
||
try: | ||
auth_token = json.loads(os.environ["API_AUTH"]) | ||
auth_token = auth_token["auth-token"] | ||
except KeyError: | ||
print("API_AUTH environment variable should be set to a json containing auth-token") | ||
sys.exit(1) | ||
|
||
headers = {"authorizationToken": auth_token} | ||
|
||
# Delete schema request | ||
response = requests.delete( | ||
url=url, | ||
headers=headers, | ||
) | ||
|
||
if response.status_code != 200: | ||
print(f"Error deleting data product schema. Status code: {response.status_code}") | ||
print(f"Error deleting data product schema. Response: {response.text}") | ||
print("Exiting...") | ||
sys.exit(1) | ||
|
||
response_json = response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters