Skip to content

Commit

Permalink
Restructure the folder and add terraform files to the frontend folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutai-Gilbert committed Nov 18, 2024
1 parent 6df207f commit 6690d7d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions frontend/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
provider "aws" {
region = var.region
}

resource "aws_s3_bucket" "frontend_bucket" {
bucket = "my-react-frontend-bucket"
acl = "public-read"
force_destroy = true

website {
index_document = "index.html"
error_document = "index.html"
}
}

resource "aws_cloudfront_distribution" "cdn" {
origin {
domain_name = aws_s3_bucket.frontend_bucket.bucket_regional_domain_name
origin_id = "S3-my-react-frontend-bucket"
}

default_cache_behavior {
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "S3-my-react-frontend-bucket"

viewer_protocol_policy = "redirect-to-https"
}

enabled = true
is_ipv6_enabled = true
default_root_object = "index.html"
}
7 changes: 7 additions & 0 deletions frontend/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "s3_bucket_name" {
value = aws_s3_bucket.frontend_bucket.bucket
}

output "cloudfront_url" {
value = aws_cloudfront_distribution.cdn.domain_name
}
Empty file added frontend/terraform/provider.tf
Empty file.
3 changes: 3 additions & 0 deletions frontend/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "region" {
default = "us-east-1"
}

0 comments on commit 6690d7d

Please sign in to comment.