The Google Kubernetes Engine cluster $GKE_CLUSTER_NAME is running inside of Google Cloud Platform (GCP) project $GCP_PROJECT_NAME with a matching Terraform configuration stored inside of container_cluster.tf that can be checked with:
terraform plan
#=>
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
I wish to enable Config Connector (more on that here) for $GKE_CLUSTER_NAME using Terraform by adding the following arguments to container_cluster.tf:
resource "google_container_cluster" ". . ." {
addons_config {
config_connector_config {
enabled = true
}
. . .
}
but when I go to plan this change I encounter the following error:
terraform plan
#=>
╷
│ Error: Unsupported block type
│
│ on container_cluster.tf line 3, in resource "google_container_cluster" ". . .":
│ 3: config_connector_config {
│
│ Blocks of type "config_connector_config" are not expected here.
even though the official documentation, found here, states that config_connector_config is supported by the addons_config block.
I am using the latest versions of Terraform and the google provider:
terraform version
#=>
Terraform v1.0.6
on . . .
+ provider registry.terraform.io/hashicorp/google v3.84.0
What change do I need to make so that I can successfully enable Config Connector for $GKE_CLUSTER_NAME using Terraform?
The
config_connector_configargument is still in Beta, so you will need to use thegoogle-betaprovider for$GKE_CLUSTER_NAME:Add the
providerargument for every resource:specify
google-betafor any resource (e.g.,$GKE_CLUSTER_NAME) with at least one Beta argument:specify
googlefor all other resources:even though the
providerarg. is not found in the official reference documentation forgoogle_container_clusterhere.Add the
google-betaprovider alongside thegoogleprovider found in aproviders.tffile:It is safe to use both
googleandgoogle-betaproviders in the same Terraform config. More on that here.Note: setting your GCP project name in the provider definitions above allows you to run
importcommands (found here) without specifying your project.Attempts to
planorapplyyour changes so far can result in the following:so you may have to
initagain:The
providerscommand should now confirm thatgoogle-betais required by your current configuration:Run a
planto confirm Config Connector will be enabled:and then
applyyour changes:Check to see if Config Connector is enabled for your cluster:
Want to learn more about using the
google-betaprovider? Visit here and here.