-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98e6489
commit 439b440
Showing
10 changed files
with
486 additions
and
161 deletions.
There are no files selected for viewing
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
200 changes: 100 additions & 100 deletions
200
infra/app/modules/aws/cloudfront/distribution/documentssstore.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,100 @@ | ||
#resource "aws_cloudfront_distribution" "s3_distribution" { | ||
# origin { | ||
# domain_name = aws_s3_bucket.b.bucket_regional_domain_name | ||
# origin_access_control_id = aws_cloudfront_origin_access_control.default.id | ||
# origin_id = local.s3_origin_id | ||
# } | ||
# | ||
# enabled = true | ||
# is_ipv6_enabled = true | ||
# comment = "Some comment" | ||
# | ||
# logging_config { | ||
# include_cookies = false | ||
# bucket = "mylogs.s3.amazonaws.com" | ||
# prefix = "myprefix" | ||
# } | ||
# | ||
# aliases = ["mysite.example.com", "yoursite.example.com"] | ||
# | ||
# default_cache_behavior { | ||
# allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"] | ||
# 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 | ||
# } | ||
# | ||
# # Cache behavior with precedence 0 | ||
# ordered_cache_behavior { | ||
# path_pattern = "/content/immutable/*" | ||
# allowed_methods = ["GET", "HEAD", "OPTIONS"] | ||
# cached_methods = ["GET", "HEAD", "OPTIONS"] | ||
# target_origin_id = local.s3_origin_id | ||
# | ||
# forwarded_values { | ||
# query_string = false | ||
# headers = ["Origin"] | ||
# | ||
# cookies { | ||
# forward = "none" | ||
# } | ||
# } | ||
# | ||
# min_ttl = 0 | ||
# default_ttl = 86400 | ||
# max_ttl = 31536000 | ||
# compress = true | ||
# viewer_protocol_policy = "redirect-to-https" | ||
# } | ||
# | ||
# # Cache behavior with precedence 1 | ||
# ordered_cache_behavior { | ||
# path_pattern = "/content/*" | ||
# allowed_methods = ["GET", "HEAD", "OPTIONS"] | ||
# cached_methods = ["GET", "HEAD"] | ||
# target_origin_id = local.s3_origin_id | ||
# | ||
# forwarded_values { | ||
# query_string = false | ||
# | ||
# cookies { | ||
# forward = "none" | ||
# } | ||
# } | ||
# | ||
# min_ttl = 0 | ||
# default_ttl = 3600 | ||
# max_ttl = 86400 | ||
# compress = true | ||
# viewer_protocol_policy = "redirect-to-https" | ||
# } | ||
# | ||
# price_class = "PriceClass_200" | ||
# | ||
# restrictions { | ||
# geo_restriction { | ||
# restriction_type = "whitelist" | ||
# locations = ["US", "CA", "GB", "DE"] | ||
# } | ||
# } | ||
# | ||
# tags = { | ||
# Environment = "${var.environment}" | ||
# } | ||
# | ||
# viewer_certificate { | ||
# cloudfront_default_certificate = true | ||
# } | ||
#} | ||
resource "aws_cloudfront_distribution" "s3_distribution" { | ||
origin { | ||
domain_name = aws_s3_bucket.b.bucket_regional_domain_name | ||
origin_access_control_id = aws_cloudfront_origin_access_control.default.id | ||
origin_id = "${var.aws_s3_bucket_id_document}" | ||
} | ||
|
||
enabled = true | ||
is_ipv6_enabled = true | ||
comment = "Some comment" | ||
|
||
logging_config { | ||
include_cookies = false | ||
bucket = "mylogs.s3.amazonaws.com" | ||
prefix = "myprefix" | ||
} | ||
|
||
aliases = ["mysite.example.com", "yoursite.example.com"] | ||
|
||
default_cache_behavior { | ||
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"] | ||
cached_methods = ["GET", "HEAD"] | ||
target_origin_id = "${var.aws_s3_bucket_id_document}" | ||
|
||
forwarded_values { | ||
query_string = false | ||
|
||
cookies { | ||
forward = "none" | ||
} | ||
} | ||
|
||
viewer_protocol_policy = "allow-all" | ||
min_ttl = 0 | ||
default_ttl = 3600 | ||
max_ttl = 86400 | ||
} | ||
|
||
# Cache behavior with precedence 0 | ||
ordered_cache_behavior { | ||
path_pattern = "/content/immutable/*" | ||
allowed_methods = ["GET", "HEAD", "OPTIONS"] | ||
cached_methods = ["GET", "HEAD", "OPTIONS"] | ||
target_origin_id = local.s3_origin_id | ||
|
||
forwarded_values { | ||
query_string = false | ||
headers = ["Origin"] | ||
|
||
cookies { | ||
forward = "none" | ||
} | ||
} | ||
|
||
min_ttl = 0 | ||
default_ttl = 86400 | ||
max_ttl = 31536000 | ||
compress = true | ||
viewer_protocol_policy = "redirect-to-https" | ||
} | ||
|
||
# Cache behavior with precedence 1 | ||
ordered_cache_behavior { | ||
path_pattern = "/content/*" | ||
allowed_methods = ["GET", "HEAD", "OPTIONS"] | ||
cached_methods = ["GET", "HEAD"] | ||
target_origin_id = local.s3_origin_id | ||
|
||
forwarded_values { | ||
query_string = false | ||
|
||
cookies { | ||
forward = "none" | ||
} | ||
} | ||
|
||
min_ttl = 0 | ||
default_ttl = 3600 | ||
max_ttl = 86400 | ||
compress = true | ||
viewer_protocol_policy = "redirect-to-https" | ||
} | ||
|
||
price_class = "PriceClass_200" | ||
|
||
restrictions { | ||
geo_restriction { | ||
restriction_type = "whitelist" | ||
locations = ["US", "CA", "GB", "DE"] | ||
} | ||
} | ||
|
||
tags = { | ||
Environment = "${var.environment}" | ||
} | ||
|
||
viewer_certificate { | ||
cloudfront_default_certificate = true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
infra/app/modules/aws/cloudfront/distribution/origin_access_control.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#resource "aws_cloudfront_origin_access_control" "oac" { | ||
# name = "${var.name}-oac" | ||
# description = "${var.name}-Origine Access Control Policy" | ||
# origin_access_control_origin_type = "s3" | ||
# signing_behavior = "always" | ||
# signing_protocol = "sigv4" | ||
#} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "aws_s3_bucket_id_documents" { | ||
value = aws_s3_bucket.document.id | ||
description = "aws_s3_bucket_id_documents" | ||
} | ||
|
||
output "aws_s3_bucket_id_paste" { | ||
value = aws_s3_bucket.paste.id | ||
description = "aws_s3_bucket_id_documents" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
resource "aws_s3_bucket" "paste" { | ||
bucket = "${var.s3_bucket_paste}" | ||
|
||
tags = { | ||
Name = "${var.s3_bucket_paste}" | ||
Owner = "${var.project_name}" | ||
Environment = "${var.environment}" | ||
Region = "${var.region}" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_policy" "pastesss_allow_access_from_cloudfront" { | ||
bucket = aws_s3_bucket.paste.id | ||
policy = data.aws_iam_policy_document.pastesss_allow_access_from_cloudfront.json | ||
} | ||
|
||
data "aws_iam_policy_document" "pastesss_allow_access_from_cloudfront" { | ||
statement { | ||
principals { | ||
type = "Service" | ||
identifiers = ["cloudfront.amazonaws.com"] | ||
} | ||
|
||
actions = [ | ||
"s3:GetObject", | ||
] | ||
|
||
resources = [ | ||
aws_s3_bucket.paste.arn, | ||
"${aws_s3_bucket.paste.arn}/*", | ||
] | ||
|
||
condition { | ||
test = "StringEquals" | ||
values = ["arn:aws:cloudfront::430689894701:distribution/E2ZI5IWQWTVER"] | ||
variable = "AWS:SourceArn" | ||
} | ||
} | ||
} |
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
Oops, something went wrong.