From c8e0682aa422518d3aa8c3ce13a7d484dc3f9c52 Mon Sep 17 00:00:00 2001 From: cmurp25 Date: Thu, 12 Dec 2024 21:34:46 -0500 Subject: [PATCH 1/2] Changes in DataMigration --- cdk/data_migration/__init__.py | 2 +- cdk/data_migration/glue_script.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cdk/data_migration/__init__.py b/cdk/data_migration/__init__.py index 24338dda..9466a433 100644 --- a/cdk/data_migration/__init__.py +++ b/cdk/data_migration/__init__.py @@ -18,7 +18,7 @@ def __init__(self, scope: Construct, id: str, *, env: Environment) -> None: super().__init__(scope, id, env=env) # Define the Beta S3 bucket for CSV files - beta_bucket_name = "testing-trigger-for-glue-job" + beta_bucket_name = "csvs-for-glue-job" # Create a dedicated S3 bucket for Glue temporary data temp_bucket = s3.Bucket(self, "GlueTempBucket", diff --git a/cdk/data_migration/glue_script.py b/cdk/data_migration/glue_script.py index 8840cc03..10fe7115 100644 --- a/cdk/data_migration/glue_script.py +++ b/cdk/data_migration/glue_script.py @@ -36,8 +36,7 @@ # Rename columns to match DynamoDB schema for visit information df = df.withColumnRenamed("Timestamp", "timestamp") \ .withColumnRenamed("Where are you", "location") \ - .withColumnRenamed("CU Username (the text before your @clemson email)", "user_id") \ - .withColumn("name", lit("")) # Add an empty column for "name" + .withColumnRenamed("CU Username (the text before your @clemson email)", "user_id") # Extract and process visit data visitData = df.select("user_id", "timestamp", "location", "name") @@ -53,7 +52,6 @@ 'user_id': row.user_id, 'timestamp': row.timestamp, 'location': row.location, - 'name': "", '_ignore': "1", # Add other user attributes if needed }) From 64e5147a6110abbbfc00b31a4b7ffdb183e82fe3 Mon Sep 17 00:00:00 2001 From: Duncan Hogg Date: Thu, 12 Dec 2024 21:50:25 -0500 Subject: [PATCH 2/2] Maybe secrets manager will be nice? --- cdk/Pipeline.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cdk/Pipeline.py b/cdk/Pipeline.py index 8d2b64db..ec81555f 100644 --- a/cdk/Pipeline.py +++ b/cdk/Pipeline.py @@ -2,6 +2,8 @@ # This stack is based on the following blog post: # https://aws.amazon.com/blogs/developer/cdk-pipelines-continuous-delivery-for-aws-cdk-applications/ from aws_cdk import ( + aws_secretsmanager, + SecretValue, App, Stack, Environment @@ -37,6 +39,15 @@ def __init__(self, app: App, id: str, *, connection_arn="arn:aws:codestar-connections:us-east-1:944207523762:connection/0d26aa24-5271-44cc-b436-3ddd4e2c9842" ) + # Retrieve backend api key from secrets manager + secret_name: str = "SharedApiGatewayKey" + shared_secrets = aws_secretsmanager.Secret.from_secret_name_v2( + self, + "SharedGatewaySecrets", + secret_name + ) + shared_api_key: SecretValue = shared_secrets.secret_value_from_json("api_key") + # Commands used to build pipeline in the Build stage deploy_cdk_shell_step = ShellStep("Synth", # Use a connection created using the AWS console to authenticate to GitHub @@ -53,6 +64,10 @@ def __init__(self, app: App, id: str, *, # install dependancies for frontend 'cd site/visitor-console', 'npm install', + + f'echo "VITE_BACKEND_KEY={shared_api_key.to_string()}" > .env', + f'echo "VITE_BACKEND_KEY={shared_api_key.to_string()}" > src/.env', + f'echo "VITE_BACKEND_KEY={shared_api_key.to_string()}" > src/pages/.env', # build for beta f'VITE_API_ENDPOINT="https://{Domains("Beta").api}" npm run build',