EFFECTIVE/AT LIFE Module 2
AI for Friends/ Module 2/ Lesson 2.5

Deploying a Website to AWS S3

Learn to host your own public website from scratch by uploading your files to Amazon S3 and setting up a fast, secure domain using Route 53 and CloudFront.

45 MIN OPTIONAL
Navigating AWS

The AWS console can look intimidating, but it has one simple trick: always use the search bar at the top center of the screen. Instead of hunting through complex menus, just type the name of the service you need (e.g. "S3", "Route 53") and click the first result under the "Services" category.

1Prerequisites

Before we start, let's review what we're trying to accomplish and what you'll need ready. We'll assume you already have your website (HTML, CSS, and possibly image folders) saved on your computer.

Project goalsWhat you need
  • Upload your web files (like your index.html file) to AWS S3.
  • Configure S3 so anyone on the internet can view your page.
  • Make your site secure (the HTTPS lock icon) using CloudFront.
  • Connect your own custom domain name.
  • An active AWS (Amazon Web Services) account (see Lesson 2.4).
  • Your web project's files ready on your computer.
  • Your own domain managed with a registrar (e.g. purchased through GoDaddy or Namecheap).

2Create and Configure an S3 Bucket

The first step is creating the "container" where your website's files will live. In the AWS ecosystem, this file container is called an S3 Bucket.

1. Create the bucket
Sign in to the AWS console. In the top search bar, type S3 and click the first result. Once inside S3, look for a large orange "Create bucket" button and click it.

On the next screen, follow these rules:

2. Allow public access
By default, AWS blocks all access to your files so no one on the internet can view them. Since we want a public website, we need to remove this lock.

On that same screen, scroll down to the "Block Public Access settings for this bucket" section:

3. Configure as a static website
You'll now see a list with your newly created bucket. Click its name (in blue text) to open it. At the top you'll see several tabs (Objects, Properties, Permissions...). Click the "Properties" tab.

4. Add the Permissions Policy (Bucket Policy)
Even though you removed the general lock, you need to explicitly tell S3 to let web browsers "read" your files. Go to the top tab called "Permissions."

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
    }
  ]
}

Click "Save changes." If everything worked, the Permissions tab will show a red badge that says "Publicly accessible."

3Upload Your Files to S3

Now that your "container" is ready to act as a web server, let's upload the files from your computer.

  1. Inside your bucket, click the first tab called "Objects."
  2. Click the orange "Upload" button.
  3. Here you can drag and drop your website's files and folders straight from your computer into the box on screen. Alternatively, use the "Add files" button (for individual files like your index.html) or "Add folder" (for folders like css or images).
  4. Once you see all your files listed on screen, scroll down and click the orange "Upload" button at the bottom.
  5. Wait for the progress bar to finish and a green success message to appear. Then click "Close" in the top right.

4Get and Share Your Free Public Link

Congratulations! At this point, your website is already live on the internet. You don't need to buy a domain or configure anything else if your only goal is sharing your page with friends, professors, clients, or for your portfolio.

AWS automatically gives you a free URL tied directly to your bucket. Here's how to find it to share:

  1. Make sure you're inside your bucket in the AWS console.
  2. Click the "Properties" tab (the second tab at the top).
  3. Scroll with your mouse wheel all the way to the very bottom of that page.
  4. Find the section called "Static website hosting."
  5. Under the text "Bucket website endpoint," you'll see a blue link. It'll look something like: http://your-bucket-name.s3-website-us-east-1.amazonaws.com.
  6. Click that link. A new tab will open in your browser showing your website! Copy that address from your browser's bar and send it to anyone you'd like.
A Note About Your Free URL

You'll notice two things about this link: it's a bit long, and it starts with http:// instead of https:// (so the browser may say "Not secure"). This is completely normal and safe for static sites that don't request passwords or credit cards. It's the fastest, free way to publish on the web!

You've Finished the Essentials

For the practical purposes of this lesson, the link you got in Step 4 already gives you a website ready to share. If you don't want to spend money on a custom domain (like mydomain.com) or set up complex technical configuration in AWS, you can jump straight to the "Verification" section at the end of this page.

Steps 5 through 8 are advanced and completely optional. They're kept here as a reference guide in case you decide, in the future, to give your website a paid custom domain and bank-grade encryption (HTTPS) using CloudFront and Route 53.

5Prepare Your Domain with Route 53 (Optional)

If you want your site to have an address like mydomain.com, we'll use AWS's Route 53 service to connect a domain you've already purchased through an external registrar (GoDaddy, Namecheap, etc.).

  1. Use the AWS top search bar, type Route 53, and click the service.
  2. In the left-hand menu (if hidden, click the three-line/hamburger icon), find and click "Hosted zones."
  3. Click the orange "Create hosted zone" button.
  4. In the "Domain name" field, type your domain name (no www, just mydomain.com). Make sure the type below says "Public hosted zone" and click "Create hosted zone" below.
  5. The vital step: In the table that appears on screen, find the row where the "Type" column says NS (Name Servers). In the right-hand column ("Value"), you'll see 4 internet addresses ending in .com, .net, etc. Copy those 4 addresses.
  6. Open a new tab in your browser, go to the site of the company where you bought your domain (GoDaddy, Namecheap, etc.) and find the DNS or Nameservers settings. Replace the company's defaults by pasting in the 4 AWS gave you. (Note: AWS sometimes adds a trailing period to each address; remove it if your domain provider won't let you save them with the trailing period).

6Get an SSL Certificate (Optional)

To make your domain show the secure-site lock icon (HTTPS), we'll get a free certificate through AWS Certificate Manager (ACM).

Mandatory Requirement: US-East-1 Region

For this certificate to work globally with CloudFront, you MUST request it in the Virginia region. In the top-right corner of the AWS console (right next to your username), you'll see a city or region name. Click it and select US East (N. Virginia) us-east-1 before continuing.

  1. Use the top search bar, type Certificate Manager, and enter the service.
  2. Click "Request a certificate," choose "Request a public certificate," and press Next.
  3. Under "Fully qualified domain name," type your domain name (e.g. mydomain.com).
  4. Leave the validation method on "DNS validation" and click "Request" below.
  5. You'll see a list of certificates and yours will say Pending validation. Click your certificate's ID (the blue numbers/letters) to open its details.
  6. Find the "Domains" section partway down the page. To the right you'll see a button that says "Create records in Route 53." Click it, then click the orange "Create records" button. This automatically creates a special record proving to AWS that you own the domain.

Now be patient. Wait a few minutes (it can take 5–30 minutes) until the certificate's status turns from blue to green and says "Issued."

7Make the Site Fast and Secure with CloudFront (Optional)

S3 by itself doesn't know how to use your new security certificate. We'll use CloudFront, a service that copies your page onto servers around the world, wrapping it with your secure certificate.

  1. Use the top search bar, type CloudFront, and enter the service. Click "Create a CloudFront distribution."
  2. In the "Origin domain" field, click the blank box. A dropdown will appear; select your S3 bucket. (Ignore any yellow warning recommending "OAC" — for this public static site we don't need it.)
  3. Scroll down to the "Default cache behavior" section. Under "Viewer protocol policy," select "Redirect HTTP to HTTPS."
  4. Very important! Scroll down to find the "Web Application Firewall (WAF)" section. Make sure you select "Do not enable security protections." If you enable the firewall without realizing it, AWS could charge you unexpected monthly fees for an advanced protection service you don't need for a simple static site.
  5. Keep scrolling to the "Settings" section.
  6. Under "Alternate domain name (CNAME)," click "Add item" and type your domain (e.g. mydomain.com).
  7. Under "Custom SSL certificate," click the box and select the certificate you created in step 6 (if it doesn't appear, make sure you waited for it to say "Issued" in Virginia).
  8. In the final "Default root object" field, type index.html.
  9. Click "Create distribution" at the bottom of the page.

You'll see a banner at the top saying the distribution is "Deploying." Note the URL under the "Distribution domain name" section (a long link ending in .cloudfront.net). This process can take about 10 minutes.

8Connect Your Final Domain to CloudFront (Optional)

The last step is telling your domain (already managed by Route 53) that when someone types your web address, it should be routed to CloudFront's fast network.

  1. Search the top bar again for Route 53 and go into "Hosted zones."
  2. Click your domain's name.
  3. Click the orange "Create record" button.
  4. Make sure "Record type" is set to A - Routes traffic to an IPv4 address.
  5. To the right of the "Value" field, turn on the small "Alias" toggle.
  6. A field called "Route traffic to" will appear. Click the first box and choose "Alias to CloudFront distribution."
  7. In the search box that appears just below, paste the long CloudFront URL you copied in the previous step (the one ending in .cloudfront.net).
  8. Click the "Create records" button.

Done! Internet systems (DNS) can take anywhere from 5 minutes to a couple of hours to update worldwide. Soon, typing your own domain into a browser will load your website instantly, with its security lock active.

Optional: Automate Uploads with GitHub Actions (Advanced)

Note: this section is only for technical readers who already use version control. If you don't know what Git or GitHub are, feel free to skip it entirely — you can keep updating your page any time by simply repeating Step 3 (the "Upload" button).

If you're a developer, you can have GitHub push changes to S3 automatically every time you run a git push.

1. IAM credentials
Go to the AWS IAM console and create a User with programmatic access. Instead of using a broad policy like AmazonS3FullAccess (which grants access to every bucket in your account), create an inline policy scoped only to your bucket, using the following JSON — replace YOUR-BUCKET-NAME with the real name:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:GetObject", "s3:ListBucket", "s3:DeleteObject"],
      "Resource": [
        "arn:aws:s3:::YOUR-BUCKET-NAME",
        "arn:aws:s3:::YOUR-BUCKET-NAME/*"
      ]
    }
  ]
}

When done, copy its Access Key ID and Secret Access Key. In your GitHub repository, go to Settings > Secrets and variables > Actions, and save them as two new "Repository secrets" named AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

2. Workflow file
On your computer, at the root of your project, create the hidden folders .github/workflows and inside create a file called main.yml. Paste the following code, making sure to change the region and your bucket name:

name: Deploy to S3
on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v4
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-east-1 # Change this to your bucket's region
    - name: Deploy static site to S3
      run: aws s3 sync ./ s3://YOUR-BUCKET-NAME --delete

Commit and push. On GitHub's "Actions" tab you'll see the deployment to S3 run automatically.

Verification

You uploaded your files using the "Upload" button.
You found the "Bucket website endpoint" link under the Properties tab, clicked it, and your site loaded perfectly in your browser. You can share it now!
(Optional) If you set up Route 53 and CloudFront, visiting your custom domain shows a closed lock icon (HTTPS) next to the address.

Related Resources

Lesson complete

Congratulations! You've built real cloud infrastructure. Your website no longer lives only on your computer — it's now fast, secure, and reachable by anyone in the world through your own domain, running just like a professional site.