Zeke Sebulino
Posted on May 22, 2023
variables.tf
variable "bucketName" {
type = string
default = "example-web-app-terraform"
}
provider.tf
provider "aws" {
region = "ap-southeast-1"
profile = "zeke"
}
main.tf
resource "aws_s3_bucket" "example" {
bucket = var.bucketName
}
resource "aws_s3_bucket_public_access_block" "example" {
bucket = aws_s3_bucket.example.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_policy" "example-policy" {
bucket = aws_s3_bucket.example.id
policy = templatefile("s3-policy.json", { bucket = var.bucketName })
depends_on = [aws_s3_bucket_public_access_block.example]
}
resource "aws_s3_bucket_website_configuration" "example-config" {
bucket = aws_s3_bucket.example.bucket
index_document {
suffix = "index.html"
}
}
resource "aws_s3_object" "example-index" {
bucket = aws_s3_bucket.example.id
key = "index.html"
source = "./index.html"
content_type = "text/html"
}
💖 💪 🙅 🚩
Zeke Sebulino
Posted on May 22, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
arquitecturadesoftware C4 Model en la Nube: Implementación Práctica con AWS y Terraform
November 17, 2024