sbercloud-terraform / terraform-provider-sbercloud

Terraform SberCloud Provider
https://registry.terraform.io/providers/sbercloud-terraform/sbercloud/latest/docs
Mozilla Public License 2.0
34 stars 21 forks source link

sbercloud_dds_instance / The API does not exist or has not been published in the environment #308

Closed kuzakov closed 2 months ago

kuzakov commented 3 months ago

Hi there,

Terraform Version

1.9.4

Affected Resource(s)

Expected Behavior

Without error

Actual Behavior

Error: Resource not found: [GET https://dds.ru-moscow-1.hc.sbercloud.ru/v3/10339484ae00272f2f2fc0081d3aa7f8/instances/6423446af0f8490798db01493c345000in02/monitoring-by-seconds/switch], request_id: 616a9d01e6617ee6e285cd6ecbef60af, error message: {"error_msg":"The API does not exist or has not been published in the environment","error_code":"APIGW.0101","request_id":"616a9d01e6617ee6e285cd6ecbef60af"}

Steps to Reproduce

On existing resource

  1. terraform plan

Important Factoids

This problem began after update terraform provider from 1.12.0 to 1.12.2

0ohmresistor commented 3 months ago

Good morning! The code snippet below works correctly and creates dds_instance.

resource "sbercloud_dds_instance" "instance" {
  name              = "test"
  availability_zone = "ru-moscow-1a"
  vpc_id            = "xx"
  subnet_id         = "xx"
  security_group_id = "xx"
  password          = "xx"
  mode              = "Sharding"

  datastore {
    type           = "DDS-Community"
    version        = "3.4"
    storage_engine = "wiredTiger"
  }

  flavor {
    type      = "mongos"
    num       = 2
    spec_code = "dds.mongodb.c6.large.4.mongos"
  }
  flavor {
    type      = "shard"
    num       = 2
    storage   = "ULTRAHIGH"
    size      = 10
    spec_code = "dds.mongodb.c6.large.4.shard"
  }
  flavor {
    type      = "config"
    num       = 1
    storage   = "ULTRAHIGH"
    size      = 20
    spec_code = "dds.mongodb.c6.large.2.config"
  }

  backup_strategy {
    start_time = "08:00-09:00"
    keep_days  = "8"
  }

  tags = {
    foo   = "bar"
    owner = "terraform"
  }
}

The output is:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # sbercloud_dds_instance.instance will be created
  + resource "sbercloud_dds_instance" "instance" {
      + availability_zone     = "ru-moscow-1a"
      + charging_mode         = (known after apply)
      + db_username           = (known after apply)
      + enterprise_project_id = (known after apply)
      + id                    = (known after apply)
      + mode                  = "Sharding"
      + name                  = "test"
      + nodes                 = (known after apply)
      + password              = (sensitive value)
      + port                  = (known after apply)
      + region                = (known after apply)
      + security_group_id     = "xx"
      + ssl                   = true
      + status                = (known after apply)
      + subnet_id             = "xx"
      + tags                  = {
          + "foo"   = "bar"
          + "owner" = "terraform"
        }
      + vpc_id                = "xx"

      + backup_strategy {
          + keep_days  = 8
          + start_time = "08:00-09:00"
        }

      + datastore {
          + storage_engine = "wiredTiger"
          + type           = "DDS-Community"
          + version        = "3.4"
        }

      + flavor {
          + num       = 2
          + spec_code = "dds.mongodb.c6.large.4.mongos"
          + type      = "mongos"
        }
      + flavor {
          + num       = 2
          + size      = 10
          + spec_code = "dds.mongodb.c6.large.4.shard"
          + storage   = "ULTRAHIGH"
          + type      = "shard"
        }
      + flavor {
          + num       = 1
          + size      = 20
          + spec_code = "dds.mongodb.c6.large.2.config"
          + storage   = "ULTRAHIGH"
          + type      = "config"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

sbercloud_dds_instance.instance: Creating...
sbercloud_dds_instance.instance: Still creating... [10s elapsed]
...
sbercloud_dds_instance.instance: Still creating... [7m40s elapsed]
sbercloud_dds_instance.instance: Creation complete after 7m48s [id=a1f17a59265e4613ba63c861b27f87e8in02]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Can you please provide your terraform code, that doesn't work?

kuzakov commented 3 months ago

My code:

resource "sbercloud_dds_instance" "dds_main" {
  name = "dds_main"
  datastore {
    type           = "DDS-Community"
    version        = "4.2"
    storage_engine = "rocksDB"
  }
  availability_zone = "ru-moscow-1c"
  vpc_id            = sbercloud_vpc.xxx_vpc.id
  subnet_id         = sbercloud_vpc_subnet.xxx_subnet.id
  security_group_id = sbercloud_networking_secgroup.sg_dds_mongodb.id
  password          = "blabla"
  mode              = "ReplicaSet"
  tags = {
    "managed_by_terraform" = "true"
    }
  flavor {
    type      = "replica"
    num       = 1
    storage   = "ULTRAHIGH"
    size      = 10
    spec_code = "dds.mongodb.c6.large.2.repset"
  }
  lifecycle {
    ignore_changes = [
      password,
    ]
  }
}
ansamy commented 2 months ago

Аналогичная проблема при работе через huaweicloud_dds_instance.

Debug Output: https://gist.github.com/ansamy/7ddcc611adcb86370daf1c0872d1941f

Также открыл Issue https://github.com/sbercloud-terraform/terraform-provider-sbercloud/issues/312

0ohmresistor commented 2 months ago

We have released a new version of the provider, with hotfix for this error.