Coder Social home page Coder Social logo

snitkjaer / serverless-url-shortener Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielireson/serverless-url-shortener

0.0 2.0 0.0 186 KB

URL shortener for AWS Lambda and S3

Home Page: https://digitalbydan.com/how-to-build-a-serverless-url-shortener-using-aws-lambda-and-s3/

License: MIT License

JavaScript 67.93% HTML 32.07%

serverless-url-shortener's Introduction

Serverless URL Shortener

A lightweight URL shortener built with the Serverless Framework using AWS Lambda and S3. Each URL redirection is stored as an S3 object with the Website-Redirect-Location metadata key set to the forwarding web address. AWS Lambda is used to create an API to save these objects. The website is served from the same S3 bucket.

Screenshot

Setup

Install dependencies

Head on over to the Serverless Framework docs and run through their quick-start guide. It’s mentioned in there as part of your setup, but be sure to install the AWS CLI and configure your AWS credentials. Then run npm install to get the NPM dependencies for the project.

Add config

Create a copy of config.sample.json as config.json and then customise as appropriate for your setup.

Name Description Required
BUCKET The S3 bucket name to use. This will form part of the URL shortener website address if you're not using a custom domain. Y
S3_PARTITION The S3 partition to use. Y
REGION The AWS region to deploy to. Y
STAGE The AWS stage to deploy to. Y
API_ENDPOINT_TYPE The API Gateway endpoint type to use. Y
API_URL The URL of the endpoint that forms should be sent to. This is only known after the first deployment, so leave empty for now. Y

Deploy API

Run npm run deploy:serverless to deploy the API to AWS. The resources defined in serverless.yml will be automatically instantiated using CloudFormation. You should copy the URL of the returned endpoint to API_URL in config.json.

Build template

Run npm run build to set the form action on the website template to API_URL from config.json.

Deploy website

Run npm run deploy:static to deploy the website using the AWS CLI.

Libraries used

serverless-url-shortener's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.