mylamour / blog

Your internal mediocrity is the moment when you lost the faith of being excellent. Just do it.
https://fz.cool
62 stars 14 forks source link

How to use amazon s3 and cloudfront to host image #96

Open mylamour opened 1 year ago

mylamour commented 1 year ago
  1. create a s3 bucket

    • enable server side encryption
    • setting accees only with cloudfront ( you can do it when cloudfront was created)
      {
      "Version": "2008-10-17",
      "Id": "PolicyForCloudFrontPrivateContent",
      "Statement": [
      {
          "Sid": "AllowCloudFrontServicePrincipal",
          "Effect": "Allow",
          "Principal": {
              "Service": "cloudfront.amazonaws.com"
          },
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::your bucketname/*",
          "Condition": {
              "StringEquals": {
                  "AWS:SourceArn": "replace with your arn"
              }
          }
      }
      ]
      }
    • create folder named images and assets (this step was optional)
  2. create certicate in aws certificate manager Screenshot 2023-04-14 at 14 47 35

  3. create cloudfront instance wth s3 backend and domain binding with origin access control

    • please set https only
  4. finally, you saw it worked. Screenshot 2023-04-14 at 14 45 57 Screenshot 2023-04-14 at 14 42 40