mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
passing additional data to cloudfront distribution
This commit is contained in:
parent
56bf3c121f
commit
ce546b56f7
4 changed files with 36 additions and 6 deletions
|
|
@ -187,7 +187,10 @@ module "lambda_heat_prediction_ecr" {
|
||||||
# CDN - Cloudfront
|
# CDN - Cloudfront
|
||||||
##############################################
|
##############################################
|
||||||
module "cloudfront_distribution" {
|
module "cloudfront_distribution" {
|
||||||
source = "./modules/cloudfront"
|
source = "./modules/cloudfront"
|
||||||
bucket_name = module.s3.bucket_name
|
bucket_name = module.s3.bucket_name
|
||||||
stage = var.stage
|
bucket_id = module.s3.bucket_id
|
||||||
|
bucket_arn = module.s3.bucket_arn
|
||||||
|
bucket_domain_name = module.s3.bucket_domain_name
|
||||||
|
stage = var.stage
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
resource "aws_cloudfront_distribution" "s3_distribution" {
|
resource "aws_cloudfront_distribution" "s3_distribution" {
|
||||||
origin {
|
origin {
|
||||||
domain_name = "${aws_s3_bucket.bucket.bucket_regional_domain_name}"
|
domain_name = var.bucket_domain_name
|
||||||
origin_id = "S3-${var.bucket_name}"
|
origin_id = "S3-${var.bucket_name}"
|
||||||
|
|
||||||
s3_origin_config {
|
s3_origin_config {
|
||||||
|
|
@ -47,7 +47,7 @@ resource "aws_cloudfront_origin_access_identity" "oai" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket_policy" "bucket_policy" {
|
resource "aws_s3_bucket_policy" "bucket_policy" {
|
||||||
bucket = aws_s3_bucket.bucket.id
|
bucket = var.bucket_id
|
||||||
|
|
||||||
policy = jsonencode({
|
policy = jsonencode({
|
||||||
Version = "2012-10-17"
|
Version = "2012-10-17"
|
||||||
|
|
@ -58,7 +58,7 @@ resource "aws_s3_bucket_policy" "bucket_policy" {
|
||||||
AWS = "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${aws_cloudfront_origin_access_identity.oai.id}"
|
AWS = "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${aws_cloudfront_origin_access_identity.oai.id}"
|
||||||
}
|
}
|
||||||
Action = "s3:GetObject"
|
Action = "s3:GetObject"
|
||||||
Resource = "${aws_s3_bucket.bucket.arn}/*"
|
Resource = "${var.bucket_arn}/*"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,18 @@ variable "stage" {
|
||||||
description = "The deployment stage"
|
description = "The deployment stage"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "bucket_id" {
|
||||||
|
description = "The ID of the S3 bucket"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "bucket_arn" {
|
||||||
|
description = "The ARN of the S3 bucket"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "bucket_domain_name" {
|
||||||
|
description = "The regional domain name of the S3 bucket"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
@ -2,3 +2,15 @@ output "bucket_name" {
|
||||||
description = "The name of the S3 bucket"
|
description = "The name of the S3 bucket"
|
||||||
value = aws_s3_bucket.bucket.bucket
|
value = aws_s3_bucket.bucket.bucket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "bucket_id" {
|
||||||
|
value = aws_s3_bucket.bucket.id
|
||||||
|
}
|
||||||
|
|
||||||
|
output "bucket_arn" {
|
||||||
|
value = aws_s3_bucket.bucket.arn
|
||||||
|
}
|
||||||
|
|
||||||
|
output "bucket_domain_name" {
|
||||||
|
value = aws_s3_bucket.bucket.bucket_regional_domain_name
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue