Terraform GCP Provider Overview
The officially supported Nitric Terraform GCP Provider.
provider: nitric/gcptf@latest
The Nitric Terraform GCP Provider is currently in preview, it's not recommended for production deployments. We recommend using the Pulumi GCP Provider for production deployments until the Terraform provider is stable.
Prerequisites
The Terraform CLI is required to deploy the resulting Terraform Stack that Nitric generates. You can find the installation instructions for Terraform in the Terraform documentation.
The provider is built with the Cloud Development Kit for Terraform (CDKTF). Since CDKTF relies on Node.js, you'll need to have Node.js installed, you can read about the full CDKTF prerequisites in the CDKTF documentation.
Enabling Nitric Terraform Providers
The Nitric Terraform providers are currently in preview, to enable them you'll need to enable beta-providers
in your Nitric project. You can do this by adding the following to your project's nitric.yaml
file:
preview:- beta-providers
Google Cloud Credentials
The Terraform CLI typically uses standard GCP credential settings to authenticate with GCP. If you've used the GCP CLI to login or another standard method previously, these settings should work without modification.
Authorize gcloud
to access the Cloud Platform with Google user credentials:
gcloud auth application-default login
Google CLI Installation
Installing the Google Cloud CLI assists with credentials setup. You can install it using these summarized instructions, for more options see the Google docs.
Download & install the latest CLI release.
Create Billing Account
For Google Cloud to allow deployments, a billing account must be created and attached to the project you deploy to.
Stack Configuration
# The provider to use and it's published version# See releases:# https://github.com/nitrictech/nitric/tagsprovider: nitric/gcptf@latest# The target GCP region to deploy to# See available regions:# https://cloud.google.com/run/docs/locationsregion: my-gcp-stack-region# ID of the google cloud project to deploy intogcp-project-id: my-gcp-project-id# All configuration below is optional# The timezone that deployed schedules will run with# Format is in tz identifiers:# https://en.wikipedia.org/wiki/List_of_tz_database_time_zonesschedule-timezone: Australia/Sydney# Configure your deployed servicesconfig:# How services without a type will be deployeddefault:# configure services to deploy to Google Cloud Runcloudrun:# set 512MB of RAM# See cloudrun configuration docs here:# https://cloud.google.com/run/docs/configuring/memory-limitsmemory: 512# set a timeout of 15 seconds# https://cloud.google.com/run/docs/configuring/request-timeouttimeout: 15# Additional deployment types# You can target these types by setting a `type` in your project configurationbig-service:cloudrun:memory: 1024timeout: 60