I have resource of provider terraform-provider-yandex/yandex/resource_yandex_mdb_mongodb_cluster.go at master · yandex-cloud/terraform-provider-yandex · GitHub
I am creating mongodb using this configuration
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
}
resource "yandex_vpc_subnet" "foo" {
zone = "ru-central1-b"
network_id = "enpcb11h7qovqqv74ua6"
v4_cidr_blocks = ["10.7.0.0/24"]
}
resource "yandex_mdb_mongodb_cluster" "mongodb_cluster" {
name = "terraform_test"
description = "my super cluster"
environment = "PRODUCTION"
network_id = "enpcb11h7qovqqv74ua6"
security_group_ids = []
cluster_config {
version = "5.0"
}
database {
name = "my_test_db"
}
user {
name = "user"
password = "12345678"
}
resources_mongod {
resource_preset_id = "s3-c2-m8"
disk_type_id = "network-ssd"
disk_size = 11
}
host {
zone_id = "ru-central1-b"
subnet_id = yandex_vpc_subnet.foo.id
type = "MONGOD"
}
}
output "cluster" {
value = yandex_mdb_mongodb_cluster.mongodb_cluster
sensitive = true
}
And after creation I need one host more, so I change my config to
....
resource "yandex_mdb_mongodb_cluster" "mongodb_cluster" {
....
+ host {
+ zone_id = "ru-central1-b"
+ subnet_id = yandex_vpc_subnet.foo.id
+ type = "MONGOD"
+ }
}
...
And after terraform apply, which works as I expected, I try to use output like this
$ terraform output -json | jq .cluster.value.host
[
{
"assign_public_ip": false,
"health": "ALIVE",
"name": "rc1b-o6csqicb9gls6b36.mdb.yandexcloud.net",
"role": "PRIMARY",
"shard_name": "rs01",
"subnet_id": "e2lgv2uejni50klfbgir",
"type": "MONGOD",
"zone_id": "ru-central1-b"
},
{
"assign_public_ip": null,
"health": null,
"name": null,
"role": null,
"shard_name": null,
"subnet_id": "e2lgv2uejni50klfbgir",
"type": "MONGOD",
"zone_id": "ru-central1-b"
}
]
but I expected output without null’s.
If i run apply again then I got what I expected.
$ terraform output -json | jq .cluster.value.host
[
{
"assign_public_ip": false,
"health": "ALIVE",
"name": "rc1b-nso3tp5k9308d933.mdb.yandexcloud.net",
"role": "PRIMARY",
"shard_name": "rs01",
"subnet_id": "e2lgv2uejni50klfbgir",
"type": "MONGOD",
"zone_id": "ru-central1-b"
},
{
"assign_public_ip": false,
"health": "ALIVE",
"name": "rc1b-9bhqdxj47o80jczi.mdb.yandexcloud.net",
"role": "SECONDARY",
"shard_name": "rs01",
"subnet_id": "e2lgv2uejni50klfbgir",
"type": "MONGOD",
"zone_id": "ru-central1-b"
}
]
So what I do wrong ?