Skip to content

Instantly share code, notes, and snippets.

@tarasowski
Last active February 25, 2025 08:42
Show Gist options
  • Save tarasowski/76250c9d6e5d5fc4acf828132758b58c to your computer and use it in GitHub Desktop.
Save tarasowski/76250c9d6e5d5fc4acf828132758b58c to your computer and use it in GitHub Desktop.

Revisions

  1. tarasowski renamed this gist Feb 25, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. tarasowski revised this gist Feb 25, 2025. 1 changed file with 11 additions and 5 deletions.
    16 changes: 11 additions & 5 deletions main.yml
    Original file line number Diff line number Diff line change
    @@ -4,11 +4,17 @@ provider "aws" {

    resource "aws_s3_bucket" "static_site" {
    bucket = "my-static-site-bucket" # Change to a unique bucket name
    acl = "public-read"
    }

    resource "aws_s3_bucket_website_configuration" "static_site" {
    bucket = aws_s3_bucket.static_site.id

    index_document {
    suffix = "index.html"
    }

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

    @@ -30,5 +36,5 @@ POLICY
    }

    output "website_url" {
    value = aws_s3_bucket.static_site.website_endpoint
    value = aws_s3_bucket_website_configuration.static_site.website_endpoint
    }
  3. tarasowski created this gist Feb 25, 2025.
    34 changes: 34 additions & 0 deletions main.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    provider "aws" {
    region = "us-east-1" # Change as needed
    }

    resource "aws_s3_bucket" "static_site" {
    bucket = "my-static-site-bucket" # Change to a unique bucket name
    acl = "public-read"

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

    resource "aws_s3_bucket_policy" "static_site_policy" {
    bucket = aws_s3_bucket.static_site.id
    policy = <<POLICY
    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "${aws_s3_bucket.static_site.arn}/*"
    }
    ]
    }
    POLICY
    }

    output "website_url" {
    value = aws_s3_bucket.static_site.website_endpoint
    }