Amplify vs S3: Why is this behaviour different?

0

HI All, I'm still very much a novice with AWS and I'm following this tutorial to learn more Build a Serverless Web Application. In my own test account I've followed this tutorial without issue. I'm currently trying to apply the same tutorial in a restricted environment where I don't have access to Amplify. I figured I could get away with swapping Amplify in this tutorial S3, however I'm getting some odd behaviour.

I'm using this github repo website for both. I'm creating the bucket and uploading the files via TF.

resource "aws_s3_bucket" "mrw-example-bucket" {
  bucket = "mrw-example"

  tags = {
    Name = "mrw-example"
  }
}
resource "aws_s3_bucket_acl" "mrw-example-bucket-acl" {
  bucket = aws_s3_bucket.mrw-example-bucket.id
  acl    = "public-read"
}

resource "aws_s3_bucket_website_configuration" "mrw-example-bucket-website-config" {
  bucket = aws_s3_bucket.mrw-example-bucket.id

  index_document {
    suffix = "index.html"
  }

  error_document {
    key = "error.html"
  }
}

resource "aws_s3_bucket_public_access_block" "mrw-example-bucket-pab" {
  bucket = aws_s3_bucket.mrw-example-bucket.id

  block_public_acls   = false
  block_public_policy = false
}

resource "aws_s3_bucket_policy" "mrw-example-bucket-policy" {
  bucket = aws_s3_bucket.mrw-example-bucket.id
  policy = file("policy.json")
}

resource "aws_s3_bucket_cors_configuration" "mrw-example-cors-config" {
  bucket = aws_s3_bucket.mrw-example-bucket.id

  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["PUT", "POST", "GET"]
    allowed_origins = ["*"]
    max_age_seconds = 3000
  }
}

###WEBSITE FILES###
locals {
  content_type_map = {
    html        = "text/html",
    js          = "application/javascript",
    css         = "text/css",
    svg         = "image/svg+xml",
    jpg         = "image/jpeg",
    ico         = "image/x-icon",
    png         = "image/png",
    gif         = "image/gif",
    pdf         = "application/pdf"
  }
}

resource "aws_s3_object" "mrw-example-bucket-objects" {
  for_each = fileset("website/", "**/*.*")
  bucket   = aws_s3_bucket.mrw-example-bucket.id
  key      = each.value
  source   = "website/${each.value}"
  etag     = filemd5("website/${each.value}")
  content_type  = lookup(local.content_type_map, regex("\\.(?P<extension>[A-Za-z0-9]+)$", each.value).extension, "application/octet-stream")
}

My question to you all, is why is the behaviour different? It feels like I've missed something obvious somewhere.

질문됨 2년 전296회 조회
1개 답변
0
수락된 답변

Seems like caching issue. Cleared and resolved.

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠