IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
341 stars 670 forks source link

ibm_database - error updating database disk auto_scaling group in some regions #3038

Closed kylem-ibm closed 3 years ago

kylem-ibm commented 3 years ago

Community Note


Creating ibm_database.postgres_primary resource with disk autoscaling settings succeeds in us-south but fails in other regions (au-syd, eu-de, eu-gb, us-east).

Terraform CLI and Terraform IBM Provider Version

Terraform v1.0.5
on darwin_amd64
+ provider registry.terraform.io/ibm-cloud/ibm v1.30.1

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "ibm_database" "postgres_primary" {
  name              = var.database_name
  plan              = "standard"
  location          = var.primary_location
  service           = "databases-for-postgresql"
  resource_group_id = var.resource_group

  members_memory_allocation_mb = var.postgres_initial_memory_allocation_mb
  members_disk_allocation_mb   = var.postgres_initial_disk_allocation_mb
  service_endpoints            = var.postgres_service_endpoints

  dynamic "auto_scaling" {
    for_each = var.postgres_autoscale_settings[*]
    content {
      dynamic "disk" {
        for_each = auto_scaling.value.disk[*]
        content {
          capacity_enabled             = disk.value["capacity_enabled"]
          free_space_less_than_percent = disk.value["free_space_less_than_percent"]
          rate_period_seconds          = disk.value["rate_period_seconds"]
          rate_increase_percent        = disk.value["rate_increase_percent"]
          rate_limit_mb_per_member     = disk.value["rate_limit_mb_per_member"]
          rate_units                   = disk.value["rate_units"]
        }
      }
    }
  }

  version = var.postgres_version
}

Expected Behavior

terraform apply should succeed in all regions.

āžœ terraform apply

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:

  # ibm_database.postgres_primary will be created
  + resource "ibm_database" "postgres_primary" {
      + adminuser                    = (known after apply)
      + connectionstrings            = (known after apply)
      + groups                       = (known after apply)
      + guid                         = (known after apply)
      + id                           = (known after apply)
      + location                     = "us-south"
      + members_cpu_allocation_count = (known after apply)
      + members_disk_allocation_mb   = 10240
      + members_memory_allocation_mb = 2048
      + name                         = "schematics-postgres-test99"
      + node_count                   = (known after apply)
      + node_cpu_allocation_count    = (known after apply)
      + node_disk_allocation_mb      = (known after apply)
      + node_memory_allocation_mb    = (known after apply)
      + plan                         = "standard"
      + resource_controller_url      = (known after apply)
      + resource_crn                 = (known after apply)
      + resource_group_id            = "4911bc9541bd4a32905fb93b52394fa0"
      + resource_group_name          = (known after apply)
      + resource_name                = (known after apply)
      + resource_status              = (known after apply)
      + service                      = "databases-for-postgresql"
      + service_endpoints            = "private"
      + status                       = (known after apply)
      + tags                         = (known after apply)
      + version                      = "12"

      + auto_scaling {
          + cpu {
              + rate_increase_percent       = (known after apply)
              + rate_limit_count_per_member = (known after apply)
              + rate_period_seconds         = (known after apply)
              + rate_units                  = (known after apply)
            }

          + disk {
              + capacity_enabled             = true
              + free_space_less_than_percent = 10
              + io_above_percent             = (known after apply)
              + io_enabled                   = (known after apply)
              + io_over_period               = (known after apply)
              + rate_increase_percent        = 15
              + rate_limit_mb_per_member     = 3670016
              + rate_period_seconds          = 900
              + rate_units                   = "mb"
            }

          + memory {
              + io_above_percent         = (known after apply)
              + io_enabled               = (known after apply)
              + io_over_period           = (known after apply)
              + rate_increase_percent    = (known after apply)
              + rate_limit_mb_per_member = (known after apply)
              + rate_period_seconds      = (known after apply)
              + rate_units               = (known after apply)
            }
        }
    }

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

ibm_database.postgres_primary: Creating...
ibm_database.postgres_primary: Still creating... [10s elapsed]
ibm_database.postgres_primary: Still creating... [20s elapsed]
ibm_database.postgres_primary: Still creating... [30s elapsed]
ibm_database.postgres_primary: Still creating... [40s elapsed]
ibm_database.postgres_primary: Still creating... [50s elapsed]
ibm_database.postgres_primary: Still creating... [1m0s elapsed]

<removed for brevity>

ibm_database.postgres_primary: Still creating... [12m20s elapsed]
ibm_database.postgres_primary: Still creating... [12m30s elapsed]
ibm_database.postgres_primary: Creation complete after 12m38s [id=crn:v1:bluemix:public:databases-for-postgresql:us-south:a/e1223c9612419fcdeb04816c6aae8dfe:40a7390d-3a00-42f0-a398-13c4ece9ba6a::]

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

Actual Behavior

terraform apply fails in any region other than us-south

āžœ terraform apply          

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:

  # ibm_database.postgres_primary will be created
  + resource "ibm_database" "postgres_primary" {
      + adminuser                    = (known after apply)
      + connectionstrings            = (known after apply)
      + groups                       = (known after apply)
      + guid                         = (known after apply)
      + id                           = (known after apply)
      + location                     = "au-syd"
      + members_cpu_allocation_count = (known after apply)
      + members_disk_allocation_mb   = 10240
      + members_memory_allocation_mb = 2048
      + name                         = "kylem-delete"
      + node_count                   = (known after apply)
      + node_cpu_allocation_count    = (known after apply)
      + node_disk_allocation_mb      = (known after apply)
      + node_memory_allocation_mb    = (known after apply)
      + plan                         = "standard"
      + resource_controller_url      = (known after apply)
      + resource_crn                 = (known after apply)
      + resource_group_id            = "4911bc9541bd4a32905fb93b52394fa0"
      + resource_group_name          = (known after apply)
      + resource_name                = (known after apply)
      + resource_status              = (known after apply)
      + service                      = "databases-for-postgresql"
      + service_endpoints            = "private"
      + status                       = (known after apply)
      + tags                         = (known after apply)
      + version                      = "12"

      + auto_scaling {
          + cpu {
              + rate_increase_percent       = (known after apply)
              + rate_limit_count_per_member = (known after apply)
              + rate_period_seconds         = (known after apply)
              + rate_units                  = (known after apply)
            }

          + disk {
              + capacity_enabled             = true
              + free_space_less_than_percent = 10
              + io_above_percent             = (known after apply)
              + io_enabled                   = (known after apply)
              + io_over_period               = (known after apply)
              + rate_increase_percent        = 15
              + rate_limit_mb_per_member     = 3670016
              + rate_period_seconds          = 900
              + rate_units                   = "mb"
            }

          + memory {
              + io_above_percent         = (known after apply)
              + io_enabled               = (known after apply)
              + io_over_period           = (known after apply)
              + rate_increase_percent    = (known after apply)
              + rate_limit_mb_per_member = (known after apply)
              + rate_period_seconds      = (known after apply)
              + rate_units               = (known after apply)
            }
        }
    }

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

ibm_database.postgres_primary: Creating...
ibm_database.postgres_primary: Still creating... [10s elapsed]
ibm_database.postgres_primary: Still creating... [20s elapsed]
ibm_database.postgres_primary: Still creating... [30s elapsed]
ibm_database.postgres_primary: Still creating... [40s elapsed]
ibm_database.postgres_primary: Still creating... [50s elapsed]
ibm_database.postgres_primary: Still creating... [1m0s elapsed]

<removed for brevity>

ibm_database.postgres_primary: Still creating... [11m21s elapsed]
ibm_database.postgres_primary: Still creating... [11m31s elapsed]
ā•·
ā”‚ Error: [ERROR] Error updating database disk auto_scaling group: Request failed with status code: 404, ServerErrorResponse: {"errors":"not_found"}
ā”‚ 
ā”‚   with ibm_database.postgres_primary,
ā”‚   on postgres.tf line 1, in resource "ibm_database" "postgres_primary":
ā”‚    1: resource "ibm_database" "postgres_primary" {
ā”‚ 
ā•µ

Note that the database resource is created, however, autoscaling config is not applied.

Steps to Reproduce

  1. terraform apply in us-south region
  2. terraform apply same config in any other region
kylem-ibm commented 3 years ago

cc/ @hkantare

sjhx commented 3 years ago

Given that infra as code is intended to ensure consistency over deployments having only 1 region work is a major.

kavya498 commented 3 years ago

@kylem-ibm , Is provider block declared with above region?

provider "ibm"{
region = <region>
}

provider by default targets to us-south region.. If you are working on other regions, region should be declared in provider block..

kylem-ibm commented 3 years ago

Thanks for the quick response @kavya498, region was explicitly set in the following variables:

variable "primary_location" {
  type    = string
  default = "au-syd"
}
variable "cluster_region" {
  type    = string
  default = "au-syd"
}

but was not set in provider. Explicitly setting the region in the provider block solved this for me.