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

[Bug]: Preview Features Unable to Be Imported #3333

Closed
1 task
Ryanaldo34 opened this issue Jan 8, 2025 · 3 comments
Closed
1 task

[Bug]: Preview Features Unable to Be Imported #3333

Ryanaldo34 opened this issue Jan 8, 2025 · 3 comments
Labels
general-usage General help/usage questions

Comments

@Ryanaldo34
Copy link

Terraform CLI Version

1.10.4

Terraform Provider Version

1.0.1

Company Name

Northmarq

Terraform Configuration

terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "1.0.1"
    }
  }
  backend "azurerm" {

  }
}

provider "snowflake" {
  organization_name = "kayjkcl"
  account_name      = "northmarq"
  role              = "G.NM_DF_SERVICE_ADMIN"
  alias             = "service_admin"
  warehouse         = "NM_DF_${var.environment}_DWH"
  preview_features_enabled = [
    "snowflake_function_sql_resource",
    "snowflake_procedure_sql_resource",
    "snowflake_stage_resource",
    "snowflake_function_python_resource",
    "snowflake_materialized_view_resource",
    "snowflake_external_table_resource",
    "snowflake_database_datasource",
    "snowflake_table_resource"
  ]
}
# Resource I am trying to import
resource "snowflake_table" "warehouse_dim_date" {
  change_tracking = true
  column {
    name = "DATEKEY"
    type = "VARCHAR(16777216)"
  }
  column {
    name = "DATE"
    type = "DATE"
  }
  column {
    name = "YEAR"
    type = "DECIMAL(4, 0)"
  }
  column {
    name = "MONTH"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "MONTHNAME"
    type = "VARCHAR(16777216)"
  }
  column {
    name = "DAY"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "DAYNAME"
    type = "VARCHAR(3)"
  }
  column {
    name = "QUARTER"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "WEEK"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "DAYOFMONTH"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "DAYOFWEEK"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "DAYOFYEAR"
    type = "DECIMAL(4, 0)"
  }
  column {
    name = "FIRST_DAY_OF_MONTH"
    type = "DATE"
  }
  column {
    name = "FIRST_DAY_OF_QUARTER"
    type = "DATE"
  }
  column {
    name = "FIRST_DAY_OF_YEAR"
    type = "DATE"
  }
  column {
    name = "FIRST_DAY_OF_WEEK"
    type = "DATE"
  }
  column {
    name = "LAST_DAY_OF_MONTH"
    type = "DATE"
  }
  column {
    name = "LAST_DAY_OF_QUARTER"
    type = "DATE"
  }
  column {
    name = "LAST_DAY_OF_YEAR"
    type = "DATE"
  }
  column {
    name = "LAST_DAY_OF_WEEK"
    type = "DATE"
  }
  column {
    name = "WEEKOFYEAR"
    type = "DECIMAL(2, 0)"
  }
  column {
    name = "YEAROFWEEK"
    type = "DECIMAL(4, 0)"
  }
  column {
    name = "WEEK_OF_MONTH"
    type = "DECIMAL(9, 0)"
  }
  column {
    name = "DAY_OF_QUARTER"
    type = "DECIMAL(10, 0)"
  }
  column {
    name = "DAYS_IN_QUARTER"
    type = "DECIMAL(10, 0)"
  }
  column {
    name = "WEEK_OF_QUARTER"
    type = "DECIMAL(16, 0)"
  }
  data_retention_time_in_days = 1
  database                    = local.database
  name                        = "DIM_DATE"
  schema                      = "WAREHOUSE"
}

Category

category:import

Object type(s)

resource:procedure, resource:table

Expected Behavior

The resource imports successfully. Running terraform plan does not product this error. It only seems to occur when trying to import preview resources that already exist at snowflake objects.

Actual Behavior

snowflake_table.warehouse_dim_date: Importing from ID "NM_DF_DEV_DB01|WAREHOUSE|DIM_DATE"...
snowflake_table.warehouse_dim_date: Import prepared!
Prepared snowflake_table for import
snowflake_table.warehouse_dim_date: Refreshing state... [id=NM_DF_DEV_DB01|WAREHOUSE|DIM_DATE]

│ Error: snowflake_table_resource is currently a preview feature, and must be enabled by adding snowflake_table_resource to preview_features_enabled in Terraform configuration.

Steps to Reproduce

  1. Initialize terraform
  2. Attempt to import existing snowflake objects into the terraform state that are listed as preview features

How much impact is this issue causing?

High

Logs

No response

Additional Information

We are using terraform to deploy objects such as tables. We have some exsting tables we want to track in terraform from now on and if we cannot import the existing ones, our deployments will fail.

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@Ryanaldo34 Ryanaldo34 added the bug Used to mark issues with provider's incorrect behavior label Jan 8, 2025
@sfc-gh-asawicki sfc-gh-asawicki added general-usage General help/usage questions and removed bug Used to mark issues with provider's incorrect behavior labels Jan 9, 2025
@sfc-gh-asawicki
Copy link
Collaborator

Hey @Ryanaldo34. Thanks for reaching out to us.

As I can see, you enabled this preview feature but in the aliased provider service_admin. You have to use this aliased provider in the resource config using the provider attribute (https://developer.hashicorp.com/terraform/language/providers/configuration#selecting-alternate-provider-configurations).

@Ryanaldo34
Copy link
Author

Ryanaldo34 commented Jan 9, 2025

@sfc-gh-asawicki Oh wow, thank you so much for the help! I completely forgot about the aliased provider needing to be explicitly configured. I was going through the provider code and couldn't find any apparent issues so I figured it was something silly. Thank you so much for the quick support! Everything is working as expected now.

@sfc-gh-asawicki
Copy link
Collaborator

Great to hear that! :)

I am closing the issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general-usage General help/usage questions
Projects
None yet
Development

No branches or pull requests

2 participants