A solution framework to generate code with built-in structure and modules to accelerate your project setup.
Solutions Builder is a boilerplate tool for building repeatable solutions with the best practices in architecture on Google Cloud, including Cloud Run, GKE clusters, Test Automation, CI/CD, etc, with built-in modules including:
- Terraform boilerplate modules
- Modular microservice templates, deployable to Cloud Run or a Kubernetes cluster.
- Generating code from templates at remote Git repo (e.g. a private Git repo)
- Container image building and deploying with Skaffold
- Modules and templates based on Copier.
- CI/CD deployment templates.
Solutions Builder is designed with modules and templates. It starts from a base project skeleton, then start adding modules into this solution folder.
For example, here are the steps when creating a new solution:
- Start a new solution with a base (skeleton) code from a "root template"
- Add a Cloud Run microservice with APIs
- Add a Load Balancer with Identity-Aware Proxy
- Add CI/CD for deployment
See Quick Start section to create a sample solution.
- See Overview for overall concepts and design details.
Required dependencies:
- Python (3.10 or later)
- gcloud CLI (Latest)
- Terraform (v1.4.0 or later)
- Skaffold (v2.4.0 or later)
Optional dependencies for GKE cluster deployment:
- Kustomize (v5.0.1 or later)
Install dependencies with package managers:
-
Mac:
brew install gcloud terraform skaffold
-
Windows:
choco install gcloud terraform skaffold
-
Others
- Google Cloud Shell - See docs/guides/cloudshell.md
pip install solutions-builder
This quick start steps will create the following:
- Create a new solution folder.
- Create a new GCP project and initialize Terraform infrastructure.
- Add a FastAPI-based microservice with a sample API.
- Deploy the service to Cloud Run.
Generate a new solution in my-solution-folder
folder.
sb new my-solution-folder
This will prompt options and variables:
🎤 What is your project name? (Spaces are allowed.)
my awesome solution name
🎤 What is your Google Cloud project ID?
my-project-id
🎤 Create GCP project 'my-project-id'? (yes/no)
yes
🎤 Which Google Cloud region?
us-central1
🎤 Default deploy method? (cloudrun or gke)
Cloud Run
(...Leave the rest as default)
Once answered, it will generate the code from the template:
Copying from template
create .
create .pylintrc
create .copier-answers.yml
...
Answer questions when adding terraform_base
module:
Adding module 'terraform_base'...
🎤 Use GCS Bucket for Terraform backend?
Yes
🎤 What is your GCP billing account?
12345-12345-12345
🎤 Use GCS Bucket for Terraform backend?
Yes
Copying from template
identical .
create terraform
create terraform/stages
...
Complete. New solution folder created at ./my-solution-folder.
- At this point, you'll see a solution folder created at
./my-solution-folder
, and asb.yaml
file with all configuration about this solution folder. - See overview.md for more details about
sb.yaml
.
Next, add a Sample Cloud Run microservice using blank_service
module template:
cd my-solution-folder
sb add component sample_service -t blank_service
- Alternatively, use a template from a remote Git repo like:
sb add component sample_service -t git@github.com:GoogleCloudPlatform/solutions-builder.git/modules/blank_service
And answer the following:
This will add component 'sample_service' to 'components' folder. Continue? [Y/n]:
🎤 Resource name (lower case, alphanumeric characters, '-')?
sample-service
🎤 Which Google Cloud region?
us-central1
🎤 Add a sample API?
Yes
🎤 Does this component require the Common image?
No
🎤 Default deploy method? (cloudrun or gke)
Cloud Run
Apply all Terraform stages (in terraform/stages
folder)
sb terraform apply --all --yes
The command above will run the following:
- Init and apply all Terraform stages. (
terraform init
andterraform apply
)) - Build the sample_service container image and published to Artifact Registry. (using Skaffold)
- Deploy the sample_service container to Cloud Run. (using Terraform)
Optionally, manually build and deploy sample_service using
sb deploy
.sb deploy -m sample_service
Once deployed, you can test the Cloud Run instance at: https://console.cloud.google.com/run/detail/us-central1/sample-service
Check out CLI_USAGE.md for more CLI usages and tutorials.
- cloudshell.md - Step-by-step guidance to run Solutions Builder on Google Cloud Shell.
- cloudrun.md - The guidance if you want to deploy microservice to Cloud Run.
- gke.md - The overall development guidance on Google Kubernetes Engine.
- CONTRIBUTIONS.md - How to contribute this project, code submission process.
- DEVELOPMENT.md - Guidances on developing new templates, modules, and components.
- TROUBLESHOOTING.md - Development guide and code submission process.
-
Who are the target audience/users for this Solutions Builder?
- A: Any engineering team to start a new solution development project.
-
Can I use this template for non-Google or multi-Cloud environments?
- A: We design this Solutions Builder to work 100% out of the box with Google Cloud products. However, you could customize the solution to meet your needs on multi-Cloud environment. See Why Google Cloud for details.