项目作者: bskim45

项目描述 :
Simple flask-based URL shortener using AWS S3
高级语言: Python
项目地址: git://github.com/bskim45/s3-url-shortener.git
创建时间: 2020-01-11T15:47:42Z
项目社区:https://github.com/bskim45/s3-url-shortener

开源协议:MIT License

下载


s3-url-shortener



Docker Stars
Docker Pulls

Super simple flask-based URL shortener leveraging AWS S3

Background

For the full serverless solution, refer to Build a Serverless, Private URL Shortener | AWS Compute Blog

I hate API Gateway (you know, it’s expensive)

Architecture

  1. App(flask) -> S3 Redirect(with a optional custom domain) -> Target Site

Requirements

  • Python 3.6 or above
  • S3 Bucket(optionally custom domain)

Prerequisites

Thanks to boto3, all options for providing credentions in boto3 document is good enough.

  1. {
  2. "Version": "2012-10-17",
  3. "Statement": [
  4. {
  5. "Sid": "",
  6. "Effect": "Allow",
  7. "Action": [
  8. "s3:PutObject",
  9. "s3:GetObject",
  10. "s3:ListBucket",
  11. "s3:PutObjectAcl"
  12. ],
  13. "Resource": [
  14. "arn:aws:s3:::your_s3_bucket",
  15. "arn:aws:s3:::your_s3_bucket/*"
  16. ]
  17. }
  18. ]
  19. }

Configuration

ENV Default Required Example
PORT 5000 8080
S3_REGION us-east-1 Yes us-east-1
S3_BUCKET Yes hello-bucket
SHORT_DOMAIN https://example.com

Deploy

Old Skool Way

Clone and install requirements:

  1. $ pip install -r requirements.txt

Configure env:

  1. $ cp .env.example .env
  2. $ vi .env

Run app:

  1. $ python run.py

docker-compose

  1. $ cp docker-compose-prod.yaml docker-compose.yaml
  2. # fill in ENV values
  3. $ vi docker-compose.yaml
  4. # run
  5. $ docker-compose up -d

Helm chart

Check out helm-git plugin if you don’t want to clone entire repository

  1. $ helm install --name my-release -f values.yaml deploy/charts/s3-url-shortener

Inspired by

License

MIT licensed. See LICENSE for full details.