Skip to content

snowflake_stage to snowflake_stage_external_s3 migration using removed block + import block produces unavoidable diff #4549

@harukitake

Description

@harukitake

Terraform CLI Version

1.12.2

Terraform Provider Version

2.14.0

Company Name

No response

Terraform Configuration

removed {
    from = snowflake_stage.example
    lifecycle {
      destroy = false
    }
  }

resource "snowflake_storage_integration" "example" {
    name    = "MY_STORAGE_INTEGRATION"
    type    = "EXTERNAL_STAGE"
    enabled = true

    storage_allowed_locations = ["s3://my-bucket/"]
    storage_provider          = "S3"
    storage_aws_role_arn      = "arn:aws:iam::123456789012:role/my-role"
  }

resource "snowflake_stage_external_s3" "example" {
  database            = "MY_DATABASE"
  schema              = "MY_SCHEMA"
  name                = "MY_STAGE"
  url                 = "s3://my-bucket/"
  storage_integration = snowflake_storage_integration.example.name

  file_format {
    json {
      allow_duplicate            = "false"
      binary_format              = "HEX"
      compression                = "AUTO"
      date_format                = "AUTO"
      enable_octal               = "false"
      multi_line                 = "false"
      null_if                    = []
      replace_invalid_characters = "false"
      skip_byte_order_mark       = "true"
      strip_null_values          = "false"
      strip_outer_array          = "false"
      time_format                = "AUTO"
      timestamp_format           = "AUTO"
      trim_space                 = "false"
    }
  }
}
import {
  to = snowflake_stage_external_s3.example
  id = "\"MY_DATABASE\".\"MY_SCHEMA\".\"MY_STAGE\""
}

Category

category:import

Object type(s)

resource:stage

Expected Behavior

no diff

Actual Behavior

terraform plan shows the following diff after import:

  # snowflake_stage_external_s3.example will be updated in-place
  ~ resource "snowflake_stage_external_s3" "example" {
      ~ use_privatelink_endpoint = "false" -> "default"
        # (other attributes unchanged)

      ~ file_format {
          ~ json {
              ~ ignore_utf8_errors = "false" -> "default"
                # (other attributes unchanged)
            }
        }
    }

Steps to Reproduce

Run terraform plan with above code.

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

Setting use_privatelink_endpoint = "false" explicitly causes the following error because it conflicts with storage_integration:

  │ Error: Conflicting configuration arguments
  │
  │   "storage_integration": conflicts with use_privatelink_endpoint
  │
  │ Error: Conflicting configuration arguments
  │
  │   "use_privatelink_endpoint": conflicts with storage_integration

Setting ignore_utf8_errors = "false" explicitly also causes the following error because it conflicts with replace_invalid_characters:

  │ Error: Conflicting configuration arguments
  │
  │   "file_format.0.json.0.ignore_utf8_errors": conflicts with
  │   file_format.0.json.0.replace_invalid_characters
  │
  │ Error: Conflicting configuration arguments
  │
  │   "file_format.0.json.0.replace_invalid_characters": conflicts with
  │   file_format.0.json.0.ignore_utf8_errors

As a result, both attributes default to "default" in the config, but the imported state has "false" for both, causing an unresolvable diff.

My goal is to migrate from snowflake_stage to snowflake_stage_external_s3 without producing any diff. I want to avoid ALTER STAGE being executed on terraform apply since the actual Snowflake configuration should remain unchanged.

Is there any way to migrate without producing this diff?

Metadata

Metadata

Labels

category:importIssue connected in any way with importing objects into terraform state.general-usageImproper usage of the provider or terraform ecosystem or question about the usage.resource:stageIssue connected to the snowflake_stage resource

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions