Generate google
and google-beta
providers
#
This quickstart guides you through setting up your development environment, making a change to magic-modules
, generating provider changes to the google
and google-beta
Terraform providers, and running tests related to the change.
Before you begin #
- Install the gcloud CLI.
- In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don’t already have a project to use for testing changes to the Terraform providers, create a project instead of selecting an existing poject. After you finish these steps, you can delete the project, removing all resources associated with the project.
Go to project selector - Make sure that billing is enabled for your Google Cloud project. Learn how to check if billing is enabled on a project.
Set up your development environment #
If you are familiar with Docker or Podman, you may want to use the experimental container-based environment instead of this section.
Add the following values to your environment settings such as
.bashrc
:# Add GOPATH variable for convenience export GOPATH=$(go env GOPATH) # Add Go binaries to PATH export PATH=$PATH:$(go env GOPATH)/bin
Install goimports
go install golang.org/x/tools/cmd/goimports@latest
Clone the
magic-modules
repositorycd ~ git clone https://github.com/GoogleCloudPlatform/magic-modules.git
Run the following command from the root of your cloned
magic-modules
repository.cd magic-modules ./scripts/doctor
Expected output if everything is installed properly:
Check for go in path... found! Check for goimports in path... found! Check for git in path... found! Check for terraform in path... found! Check for make in path... found!
Generate a provider change #
In your cloned magic-modules repository, edit
mmv1/products/bigqueryanalyticshub/DataExchange.yaml
to change the description for thedisplayName
field:- name: 'displayName' type: NestedObject description: | UPDATED_DESCRIPTION
Clone the
google
andgoogle-beta
provider repositories with the following commands:git clone https://github.com/hashicorp/terraform-provider-google.git $GOPATH/src/github.com/hashicorp/terraform-provider-google git clone https://github.com/hashicorp/terraform-provider-google-beta.git $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta
Generate changes for the
google
providermake provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google" PRODUCT=bigqueryanalyticshub
Generate changes for the
google-beta
providermake provider VERSION=beta OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google-beta" PRODUCT=bigqueryanalyticshub
Confirm that the expected changes were generated
cd $GOPATH/src/github.com/hashicorp/terraform-provider-google git diff -U0 cd $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta git diff -U0
In both cases, the changes should include:
diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hudiff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go @@ -66 +66 @@ func ResourceBigqueryAnalyticsHubDataExchange() *schema.Resource { - Description: `Human-readable display name of the data exchange. The display name must contain only Unicode letters, numbers (0-9), underscores (_), dashes (-), spaces ( ), and must not start or end with spaces.`, + Description: `UPDATED_DESCRIPTION`, diff --git a/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown b/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown --- a/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown +++ b/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown @@ -63 +63 @@ The following arguments are supported: - Human-readable display name of the data exchange. The display name must contain only Unicode letters, numbers (0-9), underscores (_), dashes (-), spaces ( ), and must not start or end with spaces. + UPDATED_DESCRIPTION
Note: There may be additional changes present due to specifying a
PRODUCT=
value or due to themagic-modules
repository being out of sync with the provider repositories. This is okay as long as tests in the following section pass.
Test changes #
Set up application default credentials for Terraform
gcloud auth application-default login export GOOGLE_USE_DEFAULT_CREDENTIALS=true
Set required environment variables
export GOOGLE_PROJECT=PROJECT_ID export GOOGLE_REGION=us-central1 export GOOGLE_ZONE=us-central1-a
Replace
PROJECT_ID
with the ID of your Google Cloud project.Enable required APIs
gcloud config set project $GOOGLE_PROJECT gcloud services enable analyticshub.googleapis.com
Run all linters
cd $GOPATH/src/github.com/hashicorp/terraform-provider-google make lint cd $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta make lint
Run all unit tests
cd $GOPATH/src/github.com/hashicorp/terraform-provider-google make test cd $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta make test
Run acceptance tests for BigqueryAnalyticsHub DataExchange
cd $GOPATH/src/github.com/hashicorp/terraform-provider-google make testacc TEST=./google/services/bigqueryanalyticshub TESTARGS='-run=TestAccBigqueryAnalyticsHubDataExchange_' cd $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta make testacc TEST=./google-beta/services/bigqueryanalyticshub TESTARGS='-run=TestAccBigqueryAnalyticsHubDataExchange_'
Troubleshoot #
Too many open files #
If you are getting “Too many open files” ulimit needs to be raised.
ulimit -n 8192
Cleanup #
- Optional: Revoke credentials from the gcloud CLI.
gcloud auth revoke