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]: snowflake_task resource error_integration got unconvertible type 'sdk.AccountObjectIdentifier' #3136

Open
1 task
FrelliBB opened this issue Oct 14, 2024 · 6 comments
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@FrelliBB
Copy link

FrelliBB commented Oct 14, 2024

Terraform CLI Version

1.9.6

Terraform Provider Version

0.97.0

Terraform Configuration

data "aws_caller_identity" "current" {}

resource "snowflake_task" "this" {
  name      = upper(var.name)
  comment   = var.comment
  database  = var.database
  schema    = var.schema
  warehouse = var.warehouse

  sql_statement        = var.sql_statement
  schedule             = var.schedule
  user_task_timeout_ms = var.user_task_timeout_ms

  enabled = var.enabled

  error_integration = "MARSHMALLOW_ERROR_NOTIFICATION_${data.aws_caller_identity.current.account_id}"

  lifecycle {
    ignore_changes = [
      session_parameters,
    ]
  }
}

variable "name" {
  type        = string
  description = "The identifier (i.e. name) for the task; must be unique for the schema in which the task is created"
}

variable "comment" {
  type        = string
  description = "Specifies a comment for the task"
  default     = ""
}

variable "schema" {
  type        = string
  description = "Name of the schema in which the task will reside"
}

variable "database" {
  type        = string
  description = "Name of the database in which the task will reside"
}

variable "warehouse" {
  type        = string
  description = "Specifies the virtual warehouse that is used to execute the task"
}

variable "sql_statement" {
  type        = string
  description = "Any single SQL statement, or a call to a stored procedure, executed when the task runs"
}

variable "schedule" {
  type        = string
  description = "Specifies the schedule for periodically running the task"
}

variable "user_task_timeout_ms" {
  type        = number
  description = "Specifies the time limit on a single run of the task before it times out (in milliseconds)"
  default     = 600000
}

variable "enabled" {
  type        = bool
  description = "Specifies if the task should be started (enabled) after creation or should remain suspended (default)"
  default     = true
}

Category

category:resource

Object type(s)

resource:task

Expected Behavior

Resource is created normally.

Actual Behavior

Terraform plan fails with.

│ Error: error_integration: '' expected type 'string', got unconvertible type 'sdk.AccountObjectIdentifier', value: '&{MARSHMALLOW_ERROR_NOTIFICATION_********}'
│ 
│   with module.module_name.snowflake_task.this,
│   on .terraform/modules/module_name/snowflake/modules/task/main.tf line 10, in resource "snowflake_task" "this":
│   10: resource "snowflake_task" "this" {

Steps to Reproduce

Use the configuration and run Terraform apply.

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

It looks like it might be related to https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/3086/files#diff-cb7f0da2beafb1e661c9b5cfd7df2f625e57b4e8af1aa913257fa4901bfd9846R466. I checked the migration guide but didn't see anything about this change in it.

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@FrelliBB FrelliBB added the bug Used to mark issues with provider's incorrect behavior label Oct 14, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @FrelliBB 👋
I'm currently refactoring tasks, do you have any special characters (spaces, dots, quotes, parentheses, etc.) in the hidden value (here: ${data.aws_caller_identity.current.account_id})? It would help me test the tasks to track the error and test it with the previous / current implementation.

@sfc-gh-jcieslak sfc-gh-jcieslak self-assigned this Oct 14, 2024
@FrelliBB
Copy link
Author

FrelliBB commented Oct 14, 2024

Thanks for the quick reply. data.aws_caller_identity.current.account_id is an AWS account id so it's just a 12 digit number. Didn't share our actual value for security reasons but it would be something like 987654321000.

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity.html#account_id

@sfc-gh-jcieslak
Copy link
Collaborator

Just confirmed that the error occurs in the "old" version and the current refactored version works. I'll try to see if there's any workaround for this in the older version (If I won't find it today, I'll check tomorrow).

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Oct 14, 2024

The following workarounds for now:

  • Using unsafe_execute, and importing task in the newer version.
  • If the error integration could be added later on, just specify the task without it and add it in the newer version.
  • Downgrade to 0.96.0 because it works (seems like there was a regression introduced in 0.97.0).

@FrelliBB
Copy link
Author

We are happy to skip the upgrade 0.97.0 and wait for a correct fix. Would that be possible or would the fix be targeting GA and require a longer wait? For context we spotted this issue on automated dependabot upgrades from 0.96.0 to 0.97.0, so we can skip this version for now.

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Oct 15, 2024

Ok 👍 the fix should be a part of 0.98.0 or 0.99.0, but it will most likely come with additional changes (e.g. field renames, etc.) that have to be migrated. That's because the refactor of tasks is done as part of preparing GA objects for v1, and all the changes will be listed in the migration guide.

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
Projects
None yet
Development

No branches or pull requests

2 participants