Skip to content

Instantly share code, notes, and snippets.

@alfredlucero
Created August 14, 2020 22:17
Show Gist options
  • Save alfredlucero/d6ec26c269f41d38a52e9e7f13bc5cdd to your computer and use it in GitHub Desktop.
Save alfredlucero/d6ec26c269f41d38a52e9e7f13bc5cdd to your computer and use it in GitHub Desktop.
Security Headers Terraform - Modules for CloudFront/Lambda_Zip in apply environment folder's main.tf
# ...more modules for other environments and use cases
# We instantiate this module to zip up the lambdas/security_headers folder which holds our lambda js files
module "security_headers_lambda_zip_staging" {
source = "../../modules/lambda_zip"
source_dir_path = "security_headers"
zip_filename = "securityHeadersLambdaStaging.zip"
}
module "cloudfront-staging" {
source = "../../modules/cloudfront"
environment = "staging"
cloudfront_aliases = ["staging.app.com"]
replication_aws_region = "us-west-2"
origin_group_id = "failover-s3-app-assets"
primary_origin_id = "s3-app-assets"
secondary_origin_id = "s3-app-assets-replication"
# ...more module variables for cors, tags, etc.
# We pass in the lambda zip module outputs as variables into our CloudFront module to
# configure our security headers lambda for a certain environment
security_headers_lambda_zip = "${module.security_headers_lambda_zip_staging.lambda_zip}"
security_headers_lambda_handler = "security_headers_lambda.handler"
security_headers_lambda_function_name = "SecurityHeadersLambdaStaging"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment