From 231e62bc90d76de98e75c7b9f5ffaface65dc2c5 Mon Sep 17 00:00:00 2001 From: Cullan Carey Date: Sun, 8 May 2022 12:07:46 -0500 Subject: [PATCH] moving files to root directory --- lambda_rotate_header.tf | 7 ++++++- .../rotate_custom_headers.py => rotate_custom_headers.py | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) rename custom_header_lambda/rotate_custom_headers.py => rotate_custom_headers.py (94%) diff --git a/lambda_rotate_header.tf b/lambda_rotate_header.tf index 018cd67..e7bdda8 100755 --- a/lambda_rotate_header.tf +++ b/lambda_rotate_header.tf @@ -32,7 +32,12 @@ resource "aws_lambda_function" "rotate_custom_header_lambda" { handler = "rotate_custom_headers.lambda_handler" source_code_hash = "${data.archive_file.custom_header_lambda_zip.output_base64sha256}" - + environment { + variables = { + primary_bucket = "${var.root_domain_name}" + backup_bucket = "www.${var.root_domain_name}" + } + } runtime = "python3.8" timeout = 300 tags = { diff --git a/custom_header_lambda/rotate_custom_headers.py b/rotate_custom_headers.py similarity index 94% rename from custom_header_lambda/rotate_custom_headers.py rename to rotate_custom_headers.py index da6370f..726e531 100755 --- a/custom_header_lambda/rotate_custom_headers.py +++ b/rotate_custom_headers.py @@ -2,7 +2,7 @@ import json import random import string - +import os def get_bucket_policy(client, bucket_name): result = client.get_bucket_policy(Bucket=f"{bucket_name}") @@ -35,9 +35,8 @@ def get_cloudfront_headers(client, value): def lambda_handler(event, context): s3 = boto3.client('s3') - bucket = 'justinschoenegge.com' - backup_bucket = 'backup-justinschoenegge.com' - # header = random_pass() + bucket = os.environ['primary_bucket'] + backup_bucket = os.environ['backup_bucket'] value = random_pass() policy = get_bucket_policy(s3, bucket) backup_policy = get_bucket_policy(s3, backup_bucket)