By using AWS re:Post, you agree to the Terms of Use
/Website Hosting/

Questions tagged with Website Hosting

Sort by most recent
  • 1
  • 90 / page

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Amplify vs S3: Why is this behaviour different?

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](https://aws.amazon.com/getting-started/hands-on/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/). 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. * [Amplify hosted site](https://i.imgur.com/ZfcGqC1.png) * [S3 hosted site](https://i.imgur.com/cYx8gNN.png) I'm using this [github repo](https://github.com/alinenaoe/wildrydes-site) 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.
1
answers
0
votes
1
views
AWS-User-5216987
asked 20 days ago

Cloudfront Multiple Distributions Automatic Directs

Hello, I have a question, I have 2 cloudfront distributions with 2 different certificates / domains that point to the same S3 Bucket # main distribution is 123456789.cloudfront.net, with alternate domain + certificate: main.mydomain.com # second distribution is 987654321.cloudfront.net, with alternate domain + certificate: sub1.otherdomain.com On DNS (I use cloudflare) I have a CNAME for the main distribution domain: # main.mydomain.com cname to 123456789.cloudfront.net and I add other subdomains pointing to this other CNAME (for better management as I have many subdomains): # sub1.mydomain.com cname to main.mydomain.com but I also do point subdomain from the other domain to this (again because of management and some hardcoded links, **so I can't point it to it's own distribution**): # sub1.otherdomain.com cname to main.mydomain.com On theory I would need to use **cloudfront function to redirect the sub1.otherdomain.com to it's distribution (987654321.cloudfront.net)**, but it works without it and I don't know why (it shouldn't or there is some universal property of cloudfront I'm not aware about), because **there is no pointing / redirect from first distribution to the second one** configured, the **only DNS pointing to cloudfront is from main.mydomain.com** (cname to 123456789.cloudfront.net), and the **certificates are different**. Is it expected? Need to be sure for not having headaches on the future with production stuff.
1
answers
0
votes
7
views
Emerson Junior
asked 4 months ago
  • 1
  • 90 / page