Presigned URLs in the serverless cloud
This document will guide you through the process of creating presigned URLs in a serverless cloud environment using the Go programming language. Most applications will need some secure, server-side logic to enforce access-control. Usually, though, the “goldilocks size” for infrastructure is as little as possible. A minimum viable security solution would do well to be stateless. Presigned URLs work well here because they are inherently time limited, and thus not typically tracked (For more info see www.storj.io/blog/how-developers-can-easily-connect-storj-to-compute-for-presigned-urls)
Prerequisites
- Basic knowledge of Go programming language
- Storj account with S3 compatible (gateway) credentials
- A cloud platform account with access to serverless functions (e.g., AWS Lambda, Google Cloud Functions)
Setting Up the Go Environment
- Install Go: Download and install the latest version of Go from the official website: https://golang.org/dl/
- Set up your Go workspace: Follow the official Go documentation to set up your Go workspace: https://golang.org/doc/code.html
Presigning URLs via Amazon Lambda
Create a new Go file main.go and import the necessary packages (e.g. run go get -u)
While Amazon has quite the variety of methods to deploy code to Lambda, this example showcases the most primitive and explicit method, using the aws cli tool.
deploy.sh
trust-policy.json
Presigning URLs via Google Cloud Functions
Create a new Go file main.go and import the necessary packages (e.g. run go get -u)
deploy.sh