Skip to content

Instantly share code, notes, and snippets.

@JoaoVagner
Created July 16, 2020 14:46
Show Gist options
  • Save JoaoVagner/ebccaaad085360411db7337c027274f6 to your computer and use it in GitHub Desktop.
Save JoaoVagner/ebccaaad085360411db7337c027274f6 to your computer and use it in GitHub Desktop.
locals {
s3_origin_id = aws_s3_bucket.site.bucket_regional_domain_name
}
resource "aws_cloudfront_distribution" "s3_distribution" {
origin {
domain_name = local.s3_origin_id
origin_id = local.s3_origin_id
}
enabled = true
is_ipv6_enabled = true
comment = "gerenciado pelo terraform"
default_root_object = "index.html"
logging_config {
include_cookies = false
bucket = aws_s3_bucket.log.bucket_domain_name
prefix = "cdn"
}
# aliases = [var.domain]
default_cache_behavior {
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
target_origin_id = local.s3_origin_id
forwarded_values {
query_string = false
cookies {
forward = "none"
}
}
viewer_protocol_policy = "allow-all"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
price_class = "PriceClass_200"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
viewer_certificate {
acm_certificate_arn = "arn:aws:acm:us-east-1:617177278386:certificate/c2d83271-162e-4b87-a4db-122e5f21326b"
ssl_support_method = "sni-only"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment