I'm trying to deploy GCP composer using terraform but got the issue ->
Error: Unsupported block type on composer.tf line 43, in resource "google_composer_environment" "test": 34: encryption_config { Blocks of type "encryption_config" are not expected here.
Here is composer.tf file:
resource "google_composer_environment" "test" {
name = "dwh_composer"
region = local.default_region
config {
node_count = 3
node_config {
zone = local.default_zone
machine_type = "e2-medium"
network = google_compute_network.test.id
subnetwork = google_compute_subnetwork.test.id
service_account = google_service_account.test.name
}
software_config {
image_version = "composer-1.17.0-preview.9-airflow-2.1.1"
python_version = "3"
airflow_config_overrides = {
core-load_example = "True"
}
pypi_packages = {
numpy = ""
scipy = "==1.1.0"
}
env_variables = {
FOO = "bar"
R1 = "test5"
evvv_qqq_d = "test1"
M1 = "test3"
AIRFLOW-3 = "test2"
}
}
private_environment_config {
enable_private_endpoint = true
}
encryption_config {
kms_key_name = google_kms_crypto_key.dwh_composer_crypto_key.name
}
}
}
resource "google_kms_key_ring" "data_warehouse_kms_keyring" {
name = "data-warehouse-kms-keyring"
location = "europe-west4"
}
resource "google_kms_crypto_key" "dwh_composer_crypto_key" {
name = "dwh-composer-crypto-key"
key_ring = google_kms_key_ring.data_warehouse_kms_keyring.self_link
}
Here is main.tf file:
terraform {
required_version = "1.0.0"
backend "gcs" {
bucket = "terraform-data-warehouse"
prefix = "gcp/data-warehouse/composer"
}
required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.70.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 3.70.0"
}
}
}
# -- Providers
provider "google" {
project = local.project_id
}
provider "google-beta" {
project = local.project_id
}
# -- common public state
data "terraform_remote_state" "common" {
backend = "gcs"
config = {
bucket = "terraform-public"
prefix = "common"
}
}
# -- Local variables
locals {
default_zone = "europe-west4-a"
default_region = "europe-west1"
project_id = "my-project"
team_group = data.terraform_remote_state.common.outputs.teams.data_warehouse.group
default_multi_region = "EU"
}
Could you help me?
The issue you're experiencing is because encryption_config
is a Beta feature in the google_composer_environment
terraform resource as per the docs . Just specify the beta provider in the resource:
resource "google_composer_environment" "test" {
name = "dwh_composer"
region = local.default_region
provider = google-beta
...
}
Don't forget to terraform init
before so that the beta Google provider will be downloaded and usable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.