Created
June 14, 2020 16:30
-
-
Save rohitg00/f6db95701a2d3ebd5bed1f7b4488d18f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creating CloutFront with S3 Bucket Origin | |
resource "aws_cloudfront_distribution" "s3-web-distribution" { | |
origin { | |
domain_name = "${aws_s3_bucket.rg-bucket.bucket_regional_domain_name}" | |
origin_id = "${aws_s3_bucket.rg-bucket.id}" | |
} | |
enabled = true | |
is_ipv6_enabled = true | |
comment = "S3 Web Distribution" | |
default_cache_behavior { | |
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"] | |
cached_methods = ["GET", "HEAD"] | |
target_origin_id = "${aws_s3_bucket.rg-bucket.id}" | |
forwarded_values { | |
query_string = false | |
cookies { | |
forward = "none" | |
} | |
} | |
viewer_protocol_policy = "allow-all" | |
min_ttl = 0 | |
default_ttl = 3600 | |
max_ttl = 86400 | |
} | |
restrictions { | |
geo_restriction { | |
restriction_type = "whitelist" | |
locations = ["IN"] | |
} | |
} | |
tags = { | |
Name = "Web-CF-Distribution" | |
Environment = "Production" | |
} | |
viewer_certificate { | |
cloudfront_default_certificate = true | |
} | |
depends_on = [ | |
aws_s3_bucket.rg-bucket | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment