Skip to content

Commit

Permalink
added lambda environment variable for cloudfront distribution id
Browse files Browse the repository at this point in the history
  • Loading branch information
Cullan Carey authored and Cullan Carey committed May 8, 2022
1 parent 042a619 commit 18b34bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_header_lambda/rotate_custom_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def random_pass():
return password

def get_cloudfront_headers(client, value):
distro = client.get_distribution_config(Id='EUCQJDP2T02XF')
distro = client.get_distribution_config(Id=f'{os.environ['cf_dist_id']}')
distro['DistributionConfig']['Origins']['Items'][0]['CustomHeaders']['Items'] = [{'HeaderName': 'Referer', 'HeaderValue': f'{value}'}]
distro['DistributionConfig']['Origins']['Items'][1]['CustomHeaders']['Items'] = [{'HeaderName': 'Referer', 'HeaderValue': f'{value}'}]
return distro['DistributionConfig'], distro['ETag']
Expand Down
1 change: 1 addition & 0 deletions lambda_rotate_header.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "aws_lambda_function" "rotate_custom_header_lambda" {
variables = {
primary_bucket = "${var.root_domain_name}"
backup_bucket = "www.${var.root_domain_name}"
cf_dist_id = aws_cloudfront_distribution.website_distribution.id
}
}
runtime = "python3.8"
Expand Down

0 comments on commit 18b34bf

Please sign in to comment.