This project demonstrates how to generate signed URLs for Google Cloud Storage (GCS) objects using Go. This allows you to share files stored in GCS without exposing the actual object's URL.
- Google Cloud Project: You'll need a Google Cloud project with the following services enabled:
- Google Cloud Storage (GCS)
- Cloud Firestore
- Google Cloud SDK: Install the Google Cloud SDK and authenticate your account.
- Go: Ensure you have Go installed on your system.
-
Create a GCS Bucket:
- Create a new GCS bucket to store your image files.
- Set appropriate permissions for the bucket to allow access for signed URL generation.
-
Create a Firestore Database:
- Create a new Firestore database to store short URLs.
- Define a collection to store the short URLs and their corresponding GCS object URLs.
-
Configure Environment Variables:
- Copy the
.env.example
file to.env
:cp .env.example .env
- Update the
.env
file with your project's specific values:GCS_BUCKET_NAME
: The name of your GCS bucket.FIRESTORE_PROJECT_ID
: The ID of your Firestore project.FIRESTORE_COLLECTION_NAME
: The name of your Firestore collection.GOOGLE_APPLICATION_CREDENTIALS
: The path to your Google Cloud service account key file.
- Copy the
- Build for Development:
make dev-build
- Start Development Console:
make dev-console
- Run in Development Mode:
go run ./main.go
-
Create a GKE Cluster:
- Create a Google Kubernetes Engine (GKE) cluster in your Google Cloud project.
-
Configure Helm Chart:
- Copy the values.yaml.example file to values.yaml:
cp ./chart/values.yaml.example ./values.yaml
- Update the values.yaml file with your project's specific values
- Copy the values.yaml.example file to values.yaml:
-
Build and Push Container Image:
- Use skaffold to build your container image and push it to Google Artifact Registry (GAR):
skaffold build -p dev --file-output=artifacts.json -d <GAR_PATH> -t "<TAG>"
- Replace <GAR_PATH> with the path to your GAR repository.
- Replace with the desired tag for your container image.
- Use skaffold to build your container image and push it to Google Artifact Registry (GAR):
-
Deploy to GKE:
- Use skaffold to deploy your application to your GKE cluster:
skaffold deploy -p prod -a artifacts.json
- Use skaffold to deploy your application to your GKE cluster: