Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDS for PostgreSQL instance is tainted right after being created with a parameter that requires a reboot #6266

Open
gutierrezps opened this issue Jan 27, 2025 · 0 comments

Comments

@gutierrezps
Copy link

Terraform Version

Terraform v1.10.0
on windows_amd64
+ provider registry.terraform.io/huaweicloud/huaweicloud v1.72.1

Terraform Configuration Files

terraform {
  required_providers {
    huaweicloud = {
      source  = "huaweicloud/huaweicloud"
      version = "1.72.1"
    }
  }
}

provider "huaweicloud" {
  region     = "sa-brazil-1"
  access_key = var.hwc_access_key
  secret_key = var.hwc_secret_key
}

resource "huaweicloud_vpc" "test" {
  name = "vpc-test"
  cidr = "10.0.0.0/16"
}

resource "huaweicloud_vpc_subnet" "test" {
  name       = "subnet-test"
  cidr       = "10.0.0.0/24"
  gateway_ip = "10.0.0.1"
  vpc_id     = huaweicloud_vpc.test.id
}

resource "huaweicloud_networking_secgroup" "test" {
  name                 = "sg-test"
  delete_default_rules = true
}

resource "huaweicloud_rds_instance" "instance" {
  name                = "rds-test"
  flavor              = "rds.pg.n1.large.2.ha"
  ha_replication_mode = "async"
  vpc_id              = huaweicloud_vpc.test.id
  subnet_id           = huaweicloud_vpc_subnet.test.id
  security_group_id   = huaweicloud_networking_secgroup.test.id
  availability_zone   = ["sa-brazil-1a", "sa-brazil-1b"]

  db {
    type     = "PostgreSQL"
    version  = "16"
    password = var.password
  }

  volume {
    type = "CLOUDSSD"
    size = 40
  }

  parameters {
    name  = "cron.timezone"
    value = "America/Sao_Paulo"
  }
}

Debug Output

https://gist.github.com/gutierrezps/fa02621e7fa549b3ab8b7d64f2507bbb

> terraform apply
...
huaweicloud_rds_instance.instance: Still creating... [6m30s elapsed]
huaweicloud_rds_instance.instance: Still creating... [6m30s elapsed]

 Error: error rebooting for RDS instance (**rds_id**): Expected HTTP response code [200 202] when accessing [POST https://rds.sa-brazil-1.myhuaweicloud.com/v3/**project_id**/instances/**rds_id**/action], but got 409 instead.
│ request_id: **request_id**, error message: {"error_msg":"Another operation is being performed on the DB instance or the DB instance is faulty.","error_code":"DBS.200452"}   
│
│   with huaweicloud_rds_instance.instance,
│   on main.tf line 33, in resource "huaweicloud_rds_instance" "instance":
│   33: resource "huaweicloud_rds_instance" "instance" {

> terraform plan
...
Terraform will perform the following actions:

  # huaweicloud_rds_instance.instance is tainted, so must be replaced
-/+ resource "huaweicloud_rds_instance" "instance" {
 ...

Expected Behavior

RDS should be created successfully and saved to the state file.

Actual Behavior

RDS instance is created in the cloud account, the parameter is updated (confirmed in the Console), but since the parameter cron.timezone is only effective upon reboot, Terraform attempted to reboot the instance. The reboot failed (as seen in the error message above), so Terraform considers the RDS instance is tainted and replaces it in the next time terraform apply is executed.

Image

Steps to Reproduce

  1. terraform init
  2. terraform apply -- it fails to reboot the instance
  3. terraform apply -- it shows the RDS resource is tainted and needs to be replaced

Additional Context

cron.timezone parameter from RDS for PostgreSQL instance is only effective upon reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant