terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

snowflake_stage does not work for existing storage_integration

Open axthosarouris opened this issue 2 years ago • 5 comments

Provider Version

0.73

Terraform Version

1.6.1

Describe the bug

Given the following code:


resource "snowflake_storage_integration" "storage_integration" {
  depends_on = [
    snowflake_role_grants.current_user_role,
    snowflake_database_grant.snowpipe_uses_database,
    snowflake_schema_grant.snowpipe_uses_schema,
    snowflake_warehouse_grant.grant_warehouse_usage
  ]
  provider                  = snowflake
  name                      = "PROFILES_INTEGRATION_${var.DATABASE}"
  type                      = "EXTERNAL_STAGE"
  enabled                   = true
  storage_provider          = "S3"
  storage_allowed_locations = local.allowed_locations
  storage_aws_object_acl    = "bucket-owner-full-control"
  storage_aws_role_arn      = var.SNOWFLAKE_AWS_ROLE_ARN
}


resource "snowflake_stage" "profiles_stage" {
  name                = "PROFILES_STAGE"
  url                 = var.S3_FOLDER
  database            = var.DATABASE
  schema              = snowflake_schema.schema.name
  storage_integration = snowflake_storage_integration.storage_integration.name
}

The output is

 Error: error creating stage 
│ 
│   with snowflake_stage.profiles_stage,
│   on common_resources_for_all_pipes.tf line 63, in resource "snowflake_stage" "profiles_stage":
│   63: resource "snowflake_stage" "profiles_stage" {

Expected behavior

The stage creation should not fail when the storage integration is provided. The equivalent script that implements the expected behavior is the following:

resource "snowsql_exec" "profiles_stage" {
  depends_on = [snowsql_exec.json_gziped]
  name       = "PROFILES_STAGE"
  create {
    statements           = <<-EOT
        USE DATABASE ${data.snowflake_database.database.name};
        USE SCHEMA ${snowflake_schema.schema.name};
        CREATE OR REPLACE STAGE PROFILES
        URL = '${var.S3_FOLDER}/'
        STORAGE_INTEGRATION = ${snowflake_storage_integration.storage_integration.name};
      EOT
    number_of_statements = 3
  }

Code samples and commands

See above

Additional context Line 63 mentioned in the error is the line starting with resource "snowflake_stage" "profiles_stage".

axthosarouris avatar Oct 13 '23 10:10 axthosarouris

Any updates here? Having the same issue, I believe. Also, the error message is quite unclear as to what the problem is exactly 🤔

tiredoak avatar Dec 13 '23 21:12 tiredoak

Hey @axthosarouris. Thanks for reporting the issue.

Could you please provide the complete debug log with the error cause? The snippet you provided is just a result, but the reason is missing.

@tiredoak, could you provide yours too?

sfc-gh-asawicki avatar Dec 14 '23 08:12 sfc-gh-asawicki

I have the same issue with Provider Version both 0.73.0 and 0.84.1. any update here? her eis the errors I founf in the log file :

2024-01-30T11:14:00.154Z [ERROR] provider.terraform-provider-snowflake_v0.73.0: Response contains error diagnostic: diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="error creating stage APPFLOW_JIRA" tf_proto_version=5.4 tf_provider_addr=registry.terraform.io/Snowflake-Labs/snowflake @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto tf_req_id=003e2ab9-3efd-30ef-62db-4ff75ab2e3a8 tf_resource_type=snowflake_stage tf_rpc=ApplyResourceChange timestamp=2024-01-30T11:14:00.154Z
2024-01-30T11:14:00.155Z [ERROR] vertex "module.jira_sf_schema_and_stage.snowflake_stage.snowflake_stage" error: error creating stage APPFLOW_JIRA```

amofakhar avatar Jan 30 '24 11:01 amofakhar

Hey @amofakhar. Could you provide the full debug log for the first error? You can get more output by running terraform with TF_LOG=DEBUG flag.

sfc-gh-asawicki avatar Jan 30 '24 17:01 sfc-gh-asawicki

Hey @amofakhar, @tiredoak, @axthosarouris. Could any of you provide the full debug log for the errors? You can get more output by running the terraform with the TF_LOG=DEBUG flag.

sfc-gh-asawicki avatar Feb 16 '24 13:02 sfc-gh-asawicki

Closing due to inactivity. Please open a new issue if the problem persists in the newest provider version. Please remember about the debug log (with TF_LOG=DEBUG flag enabled)

sfc-gh-asawicki avatar Mar 13 '24 13:03 sfc-gh-asawicki