Skip to content

sqlserverflex_instance: setting retention_days causes "Provider produced inconsistent result" error #1322

@chefcook

Description

@chefcook

Description

The options.retention_days field on stackit_sqlserverflex_instance is documented as Optional and accepts values between 30 and 365 according to the STACKIT MSSQL Flex API docs.

However, the API silently ignores the value on creation and always returns the default 32 when read back.

This causes Terraform to error with "Provider produced inconsistent result after apply" because it sent 90 but received 32 in the confirmation read.

Steps to reproduce

resource "stackit_sqlserverflex_instance" "sql_instance" {
  project_id      = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  name            = "example-instance"
  acl             = ["xxx.xxx.xxx.xxx/32"]
  backup_schedule = "0 0 * * *"
  flavor = {
    cpu = 4
    ram = 16
  }
  storage = {
    class = "premium-perf10-stackit"
    size  = 500
  }
  version = 2022
  options = {
    retention_days = 90
  }
}
  1. Run terraform plan plan shows retention_days = 90 will be set
  2. Run terraform apply provider sends retention_days = 90 to the API
  3. API accepts the request and creates the instance
  4. Provider reads back the instance to confirm API returns retention_days = 32 regardless of the value sent
  5. Terraform errors with inconsistent result

Actual behavior

Error: Provider produced inconsistent result after apply

When applying changes to stackit_sqlserverflex_instance.sql_instance,
provider "provider[\"registry.terraform.io/stackitcloud/stackit\"]"
produced an unexpected new value:
.options.retention_days: was cty.NumberIntVal(90), but now cty.NumberIntVal(32).

Expected behavior

The API should persist the retention_days value provided during instance creation and return it consistently on subsequent GET requests. Setting retention_days = 90 should result in the instance having a 90-day backup retention period, and the API should return 90 when the instance is read back.

If the field is not yet settable via the API, the provider should either mark retention_days as Computed only (removing it from Optional) or document that it cannot be changed from the default, to prevent users from hitting this error.

Environment

  • OS: Windows 11 x64
  • Terraform version: v1.14.7
  • Version of the STACKIT Terraform provider: v0.88.0

Additional information

The STACKIT MSSQL Flex API v2 documentation at https://docs.api.stackit.cloud/documentation/mssql-flex-service/version/v2#tag/instance/paths/~1v2~1projects~1%7BprojectId%7D~1regions~1%7Bregion%7D~1instances/post lists retentionDays as a valid POST field accepting values 30–365 with a default of 32.

Workaround: remove the options block entirely from the resource definition until this is resolved.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions