This Terraform configuration is designed to set up Google Cloud Platform (GCP) infrastructure required to create a Databricks workspace within customers GCP project including the creation of subnets, Private Service Connect (PSC) subnets, and necessary firewall rules. It also includes the option to create Customer Managed Keys (CMK) for encryption. Please note that we are only creating pre-requistes required to provision a Databricks workspace. Depending upon your needs you could create workspaces:
create_psc_resources and create_cmk_resources set to false in terraform.tfvarscreate_psc_resources set to true in terraform.tfvarscreate_cmk_resources set to true in terraform.tfvarscreate_psc_resources and create_cmk_resources set to true in terraform.tfvars
To successfully create the resources defined in this Terraform configuration, ensure that the service account or user account you are using has the following IAM roles:
variables.tfThis file defines the variables used in the Terraform configuration. Key variables include:
vpc_project_id: The GCP project ID where the VPC will be created.network_name: The name of the VPC network.subnet_configs: Configurations for the subnets, including region and CIDR.psc_subnet_configs: Configurations for the PSC subnets.create_psc_resources: Flag to enable or disable the creation of PSC resources.This allows us to create a BYOVPC + PSC workspacecreate_cmk_resources: Flag to enable or disable the creation of KMS resources. This allows us to create a BYOVPC + CMK workspaceterraform.tfvarsThis file contains the values for the variables defined in variables.tf. You can customize the values according to your requirements. Key configurations include:
vpc_project_id: Your GCP project ID.network_name: The desired name for the VPC.subnet_configs: Define the subnets you want to create.psc_subnet_configs: Define the PSC subnets you want to create.psc_attachments: Define the workspace and relay attachments for each region.create_psc_resources: Flag to enable or disable the creation of PSC resources.create_cmk_resources: Flag to enable or disable the creation of KMS resources.Rename terraform.tfvars.remove: Rename terraform.tfvars.remove by removing remove from the end of the file extension. Update variables so that it has your desired values
Initialize Terraform: Run the following command to initialize Terraform and download the necessary provider plugins.
terraform init
Plan the Deployment: Generate an execution plan to see what resources will be created.
terraform plan
Apply the Configuration: Apply the Terraform configuration to create the resources in GCP.
terraform apply
Confirm the action when prompted.
Verify Resources: After the apply completes, you can verify the created resources in the GCP Console or by running
terraform output
To destroy all resources created by this configuration, run:
terraform destroy
Confirm the action when prompted.
terraform.tfvars file to customize the setup according to your needs.