Skip to content

Instantly share code, notes, and snippets.

@arbabnazar
Last active November 3, 2020 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbabnazar/07824991135a3125ca4b1c23c644d5a4 to your computer and use it in GitHub Desktop.
Save arbabnazar/07824991135a3125ca4b1c23c644d5a4 to your computer and use it in GitHub Desktop.
// Setup the CloudFront Distribution
resource "aws_cloudfront_distribution" "cloudfront_distribution" {
origin {
domain_name = "${var.bucket_name}.s3.amazonaws.com"
origin_id = "S3-${var.bucket_name}"
s3_origin_config {}
}
enabled = true
price_class = "${var.price_class}"
default_cache_behavior {
allowed_methods = [ "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT" ]
cached_methods = [ "GET", "HEAD" ]
target_origin_id = "S3-${var.bucket_name}"
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
viewer_protocol_policy = "allow-all"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
retain_on_delete = "${var.retain_on_delete}"
viewer_certificate {
cloudfront_default_certificate = true
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment