Commit 3d7522d3 authored by Bertrand PINEL's avatar Bertrand PINEL

Complete Terraform script after trying a full rebuild

parent 46d3e245
......@@ -25,3 +25,120 @@ resource "aws_s3_bucket" "staging" {
error_document = "index.html"
}
}
locals {
s3_origin_id = "S3Origin"
}
resource "aws_cloudfront_distribution" "s3_distribution_production" {
origin {
domain_name = "${element(split("/","${aws_s3_bucket.production.website_endpoint}"),2)}"
origin_id = "${local.s3_origin_id}"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["SSLv3", "TLSv1.1", "TLSv1.2"]
}
}
enabled = true
http_version = "http2"
is_ipv6_enabled = true
comment = "Production ehipster ClondFront"
default_root_object = "index.html"
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
compress = true
cached_methods = ["GET", "HEAD"]
target_origin_id = "${local.s3_origin_id}"
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = {
Environment = "production"
}
viewer_certificate {
cloudfront_default_certificate = true
}
}
resource "aws_cloudfront_distribution" "s3_distribution_staging" {
origin {
domain_name = "${element(split("/","${aws_s3_bucket.staging.website_endpoint}"),2)}"
origin_id = "${local.s3_origin_id}"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["SSLv3", "TLSv1.1", "TLSv1.2"]
}
}
enabled = true
http_version = "http2"
is_ipv6_enabled = true
comment = "Staging ehipster ClondFront"
default_root_object = "index.html"
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
compress = true
cached_methods = ["GET", "HEAD"]
target_origin_id = "${local.s3_origin_id}"
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = {
Environment = "staging"
}
viewer_certificate {
cloudfront_default_certificate = true
}
}
locals {
s3_origin_id = "S3Origin"
}
data "aws_s3_bucket" "production" {
bucket = "${var.bucket_name_production}"
}
data "aws_s3_bucket" "staging" {
bucket = "${var.bucket_name_staging}"
}
resource "aws_cloudfront_distribution" "s3_distribution_production" {
origin {
domain_name = "${element(split("/","${data.aws_s3_bucket.production.website_endpoint}"),2)}"
origin_id = "${local.s3_origin_id}"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["SSLv3", "TLSv1.1", "TLSv1.2"]
}
}
enabled = true
http_version = "http2"
is_ipv6_enabled = true
comment = "Production ehipster ClondFront"
default_root_object = "index.html"
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
compress = true
cached_methods = ["GET", "HEAD"]
target_origin_id = "${local.s3_origin_id}"
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = {
Environment = "production"
}
viewer_certificate {
cloudfront_default_certificate = true
}
}
resource "aws_cloudfront_distribution" "s3_distribution_staging" {
origin {
domain_name = "${element(split("/","${data.aws_s3_bucket.staging.website_endpoint}"),2)}"
origin_id = "${local.s3_origin_id}"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["SSLv3", "TLSv1.1", "TLSv1.2"]
}
}
enabled = true
http_version = "http2"
is_ipv6_enabled = true
comment = "Staging ehipster ClondFront"
default_root_object = "index.html"
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
compress = true
cached_methods = ["GET", "HEAD"]
target_origin_id = "${local.s3_origin_id}"
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = {
Environment = "staging"
}
viewer_certificate {
cloudfront_default_certificate = true
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment