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_config
argument is still in Beta, so you will need to use thegoogle-beta
provider for$GKE_CLUSTER_NAME
:Add the
provider
argument for every resource:specify
google-beta
for any resource (e.g.,$GKE_CLUSTER_NAME
) with at least one Beta argument:specify
google
for all other resources:even though the
provider
arg. is not found in the official reference documentation forgoogle_container_cluster
here.Add the
google-beta
provider alongside thegoogle
provider found in aproviders.tf
file:It is safe to use both
google
andgoogle-beta
providers in the same Terraform config. More on that here.Note: setting your GCP project name in the provider definitions above allows you to run
import
commands (found here) without specifying your project.Attempts to
plan
orapply
your changes so far can result in the following:so you may have to
init
again:The
providers
command should now confirm thatgoogle-beta
is required by your current configuration:Run a
plan
to confirm Config Connector will be enabled:and then
apply
your changes:Check to see if Config Connector is enabled for your cluster:
Want to learn more about using the
google-beta
provider? Visit here and here.