-
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
Timothée Aufort
committed
Oct 17, 2024
1 parent
1ae9403
commit 796c68e
Showing
8 changed files
with
148 additions
and
0 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
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,10 @@ | ||
# Note: at the moment, it's not possible to use variables in Terraform backend | ||
terraform { | ||
backend "s3" { | ||
bucket = "twitch-live-17102024-tf-states" | ||
key = "20_cloudfront/terraform.tfstate" | ||
region = "eu-west-3" | ||
dynamodb_table = "twitch-live-17102024-tf-states-lock" | ||
encrypt = true | ||
} | ||
} |
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,44 @@ | ||
locals { | ||
origin_id = "myOriginId" | ||
} | ||
|
||
module "cdn" { | ||
source = "terraform-aws-modules/cloudfront/aws" | ||
|
||
# aliases = ["cdn.example.com"] | ||
|
||
comment = "My awesome CloudFront" | ||
enabled = true | ||
is_ipv6_enabled = true | ||
price_class = "PriceClass_All" | ||
retain_on_delete = false | ||
wait_for_deployment = false | ||
|
||
create_origin_access_identity = true | ||
|
||
origin_access_control = { | ||
s3_oac = { | ||
description = "CloudFront access to S3" | ||
origin_type = "s3" | ||
signing_behavior = "always" | ||
signing_protocol = "sigv4" | ||
} | ||
} | ||
|
||
origin = { | ||
s3_one = { | ||
domain_name = module.s3_bucket.s3_bucket_bucket_domain_name | ||
origin_access_control = "s3_oac" # key in `origin_access_control` | ||
origin_id = local.origin_id | ||
} | ||
} | ||
|
||
default_cache_behavior = { | ||
target_origin_id = local.origin_id | ||
viewer_protocol_policy = "allow-all" | ||
} | ||
# viewer_certificate = { | ||
# acm_certificate_arn = "arn:aws:acm:us-east-1:135367859851:certificate/1032b155-22da-4ae0-9f69-e206f825458b" | ||
# ssl_support_method = "sni-only" | ||
# } | ||
} |
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 @@ | ||
data "aws_caller_identity" "current" {} |
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,10 @@ | ||
provider "aws" { | ||
region = var.region | ||
|
||
default_tags { | ||
tags = { | ||
project = basename(abspath("${path.module}/../..")) | ||
subproject = basename(abspath(path.module)) | ||
} | ||
} | ||
} |
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,33 @@ | ||
locals { | ||
origin_bucket_name = "twitch-live-17102024-my-web-site-origin" | ||
} | ||
|
||
module "s3_bucket" { | ||
source = "terraform-aws-modules/s3-bucket/aws" | ||
|
||
bucket = local.origin_bucket_name | ||
acl = "private" | ||
|
||
control_object_ownership = true | ||
object_ownership = "ObjectWriter" | ||
|
||
server_side_encryption_configuration = { | ||
rule = { | ||
apply_server_side_encryption_by_default = { | ||
sse_algorithm = "AES256" | ||
} | ||
} | ||
} | ||
|
||
# policy = data.aws_iam_policy_document.origin_bucket_policy.json | ||
} | ||
|
||
|
||
# data "aws_iam_policy_document" "origin_bucket_policy" { | ||
# statement { | ||
# effect = "Allow" | ||
# principals { | ||
# | ||
# } | ||
# } | ||
# } |
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,5 @@ | ||
variable "region" { | ||
description = "Default AWS region" | ||
default = "eu-west-3" | ||
type = string | ||
} |
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 @@ | ||
terraform { | ||
required_version = "~> 1.0" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
} | ||
} |