Skip to content

vannio/serverless-shrink

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

Serverless Shrink

URL shortener API built with the Serverless framework.

Usage

Request

curl --location --request POST 'https://go.vann.io' \
--header 'Content-Type: application/json' \
--data-raw '{"url": "http://www.superlongridiculousurl.com"}'

Response

{
  "data": {
    "url": "http://www.superlongridiculousurl.com",
    "shrink": "go.vann.io/a43f3e1ce0"
  }
}

Development

Prerequisites

Initialise

  1. Generate user access and secret keys from IAM
  2. Run aws configure to set up AWS caller identity
  3. Check config by running aws sts get-caller-identity

Deployment

  1. Ensure stage config is set correctly in the vars directory*
  2. Comment out the CustomDomainMap block in serverless.yml*
  3. Run serverless deploy --stage <stage> where stage is dev or prod, eg. --stage dev
  4. Set up your custom domain name mapping in API Gateway
  5. Create and verify the accompanying SSL cert in the AWS Certificate Manager*
  6. Restore (uncomment) the CustomDomainMap block in serverless.yml*
  7. Re-run serverless deploy --stage <stage>*

*on initial deploy

Debugging

  • Logs can be found in CloudWatch
  • If things are unsalvageable, you can delete everything to start from scratch:
    1. Remove custom domain name mapping from API Gateway manually
    2. Run serverless remove --stage <stage>