Terraform script to configure S3 and Cloudfront for static website hosting. Restricted access to Cloudfront via referer header, custom domain, and so on.
Mostly just playing around with Terraform based on the documentation.
- Terraform
- AWS Account
terraform init
cp environment.tfvars.example environment.tfvars
and change as needed (see Settings section)- Verify:
terraform plan -var-file=environment.tfvars
- Invoke:
terraform apply -var-file=environment.tfvars
- Destroy:
terraform destroy -var-file=environment.tfvars
region = AWS_REGION
profile = AWS_PROFILE
s3_bucket = BUCKET_NAME_YOU_WANT
s3_origin_id = BUCKET_ORIGIN_ID (also used for referer header)
aliases = LIST_OF_DOMAINS
acm_certificate_arn = ACM CERTIFICATE ARN