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

snowflake_stage does not work for existing storage_integration #2120

Closed
axthosarouris opened this issue Oct 13, 2023 · 6 comments
Closed

snowflake_stage does not work for existing storage_integration #2120

axthosarouris opened this issue Oct 13, 2023 · 6 comments
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:stage Issue connected to the snowflake_stage resource

Comments

@axthosarouris
Copy link

axthosarouris commented Oct 13, 2023

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 axthosarouris added the bug Used to mark issues with provider's incorrect behavior label Oct 13, 2023
@tiredoak
Copy link

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

@sfc-gh-asawicki
Copy link
Collaborator

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?

@amofakhar
Copy link

amofakhar commented Jan 30, 2024

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```

@sfc-gh-asawicki
Copy link
Collaborator

sfc-gh-asawicki commented Jan 30, 2024

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
Copy link
Collaborator

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
Copy link
Collaborator

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-jcieslak sfc-gh-jcieslak added category:resource resource:stage Issue connected to the snowflake_stage resource labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:stage Issue connected to the snowflake_stage resource
Projects
None yet
Development

No branches or pull requests

5 participants