GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - zoph-io/serverless-aws-https-webredirect: Serverless AWS HTTPS Webredirect

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
assets
assets
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
config.json
config.json
 
 
template.yml
template.yml
 
 

Repository files navigation

🔀 Serverless AWS WebRedirect

đŸ“Ŗ Intro

Previously, this blueprint used Route53 records associated with a static web hosting-enabled S3 bucket. The trade-off of this pattern was it only supports HTTP protocol. Red flag 🚩

Nowadays, there are much better options using Amazon CloudFront and CloudFront function. It's still serverless and supports HTTPS natively. It also enables new capabilities thanks to the newly released KeyValue Store feature in CloudFront.

This revised version will let you redirect subdomains to any other top-level domain, subdomains or URL.

Features

  • URL Redirect: Redirect multiple source subdomains to target URLs
  • Easy URLs Management: Manage target URLs directly using the CloudFront AWS Console

Examples:

  • blog.zoph.io -> https://zoph.me
  • asd.zoph.io -> https://awssecuritydigest.com
  • book.zoph.io -> https://calendly.com/zophio/30min-meeting/

📐 Schema

Architecture schema

🧱 AWS Building Blocks

â„šī¸ The following assets will be deployed to your AWS account.

  1. CloudFront Distribution
  2. CloudFront Function
  3. CloudFront KeyValueStore
  4. S3 Buckets
  5. S3 Bucket Policy
  6. Route53 Records

âŒ¨ī¸ Configuration

â„šī¸ Fill the following parameters in the Makefile with your own values.

###################### Parameters ######################
ProjectName := "my-project-name" # Give a name for your project
AWSRegion := eu-west-1 # AWS Region used for deployment
SourceNakedDomain := domain.tld # Source domain
SourceSubDomainList := "sub1,sub2" # Source subdomains
R53HostedZoneId := Z1BPJ52MEEXXXX # Source domain R53 hosted zone id
# Use Wildcard Certificate if multiple subdomains
CertificateArn := "arn:aws:acm:us-east-1:...." # us-east-1 Arn of ACM Public Certificate associated
#######################################################

Setup Redirection targets

â„šī¸ Update the config.json file according to your needs

{
  "data": [
    {
      "key": "sub1.domain.tld",
      "value": "google.com"
    },
    {
      "key": "sub2.domain.tld",
      "value": "aws.amazon.com/cloudfront/"
    }
  ]
}

âŒ¨ī¸ Deployment

â„šī¸ Run the following command (where your AWS CLI is authenticated)

    $ make requirements
    $ make deploy

Give a try with this command: $ make test

📝 Update target URLs (Console)

â„šī¸ You will be able to change target url using the CloudFront Console, in the KeyValueStores section

Screenshot

❌ Remove

    $ make tear-down

đŸŽ–ī¸ Credits

  • đŸ´â€â˜ ī¸ AWS Security Boutique: zoph.io
  • 💌 AWS Security Digest Newsletter
  • đŸĻ 𝕏/Twitter: zoph

🤔 Inspiration

  • AWS BlogPost: KeyValue Store
  • AWS Documentation
  • CloudFormation Loop
  • Multiple CNAME in CloudFront

About

Serverless AWS HTTPS Webredirect

zoph.io

Topics

cloudformationhttpsredirectserverlessurlurlredirector

Resources

Readme
GPL-3.0 license
Activity
Custom properties

Stars

5 stars

Watchers

0 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.