GCP SERVERLESS API
TECH STACK
- API Gateway
- Golang
- Google Cloud Firestore (Native Mode)
- Google Cloud Functions
- Google Cloud Storage
LOCAL SETUP
git clone
andcd
into the foldergo mod download
to download modules to local cache- Create a service account, add roles
Cloud Functions Invoker
,Storage Object Admin
and private key for the account - Create a publicly accessible Google Cloud Storage Bucket
- Copy the following environmental variables to a
.env
file fromexample.env
and fill in your credentials make dev
ORgo run cmd/main.go
to start the application
GCP DEPLOYMENT
- Install the serverless framework and plugins defined in
serverless.yml
- Enable these APIs on GCP
Cloud Deployment Manager V2 API
,API Gateway API
,Service Control API
,Service Management API
,Cloud Firestore API (Native Mode)
,Cloud Function API
Cloud Storage API
- Use gcloud CLI to get application default credientials
- For each stage e.g. dev, prod, test
- Copy the following environmental variables to a
.env.
file fromexample.env
and fill in your credentials sls deploy --stage
to deploy resources- Create an API Gateway and its API config using the sample file
apiconfig-dev.yaml
. Replace the region and project id in the given file - Enable your created API e.g.
-.apigateway. .cloud.goog - Create an API Key and restrict it to your API
- Copy the following environmental variables to a