Skip to content

Commit

Permalink
read event to dict
Browse files Browse the repository at this point in the history
  • Loading branch information
timburke-hackit committed Nov 2, 2023
1 parent 3cff6aa commit 1dd0f3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lambdas/export_rds_snapshot_to_s3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@


def lambda_handler(event, context):
snapshot_identifier = event["detail"]["SnapshotIdentifier"]
source_arn = event["detail"]["SourceArn"]
bucket_name = os.environ["BUCKET_NAME"]
iam_role_arn = os.environ["IAM_ROLE_ARN"]
kms_key_id = os.environ["KMS_KEY_ID"]

event = ast.literal_eval(event)
snapshot_identifier = event["detail"]["SourceIdentifier"]
source_arn = event["detail"]["SourceArn"]

try:
rds.start_export_task(
ExportTaskIdentifier=snapshot_identifier,
Expand Down
11 changes: 7 additions & 4 deletions lambdas/rds_snapshot_export_s3_to_s3_copier/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import ast
import boto3


Expand Down Expand Up @@ -57,8 +57,8 @@ def s3_copy_folder(
continue
source_key_split = source_key.split("/")
parquet_file_name = source_key_split[-1]
database_name = source_key_split("/")[1]
table_name = source_key_split("/")[2]
database_name = source_key_split[1]
table_name = source_key_split[2]
copy_object_params = {
"Bucket": target_bucket,
"CopySource": f"{source_bucket}/{source_key}",
Expand All @@ -85,6 +85,8 @@ def start_workflow_run(workflow_name: str, glue_client):


def lambda_handler(event, context) -> None:
print("## EVENT")
print(event)
s3 = boto3.client("s3")

source_bucket = os.environ["SOURCE_BUCKET"]
Expand All @@ -98,7 +100,8 @@ def lambda_handler(event, context) -> None:
else:
target_prefix = ""

snapshot_id = event["detail"]["SnapshotIdentifier"]
event = ast.literal_eval(event)
snapshot_id = event["detail"]["SourceIdentifier"]

s3_copy_folder(
s3, source_bucket, source_prefix, target_bucket, target_prefix, snapshot_id
Expand Down

0 comments on commit 1dd0f3c

Please sign in to comment.