Open MikkelKrabbeNielsen opened 1 year ago
@sfc-gh-jlove this appears to be a syntax issue when modifying resource monitors triggers only, it adds SET
to the ALTER
statement. If only altering triggers, SET
should not be included. Re-using the credit quota is one way to solve but I believe it'd be cleaner to optionally add the SET
depending if attributes are altered or only triggers
I have a similar issue using TF Snowflake Provider v0.70.1 when I would like to update an existing Ressource Monitor with "notify_triggers", "notify_users", and "supend_immediate_trigger".
Before:
resource "snowflake_resource_monitor" "my_monitor" {
name = "MY_MONITOR"
credit_quota = 44 # per month
warehouses = "MY_WAREHOUSE"
}
After:
resource "snowflake_resource_monitor" "my_monitor" {
name = "MY_MONITOR"
credit_quota = 44 # per month
warehouses = "MY_WAREHOUSE"
notify_triggers = [50, 100] # Add
notify_users = ["MY_USER"] # Add
suspend_immediate_trigger = 100 # Add
}
Error:
error updating resource monitor MY_MONITOR
001003 (42000): SQL compilation error:
syntax error line 1 at position 62 unexpected 'ON'.
syntax error line 1 at position 77 unexpected 'DO'.
syntax error line 1 at position 98 unexpected 'ON'.
syntax error line 1 at position 112 unexpected 'DO'.
syntax error line 1 at position 122 unexpected 'ON'.
syntax error line 1 at position 137 unexpected 'DO'.
syntax error line 1 at position 146 unexpected '<EOF>'.[0m
with snowflake_resource_monitor.my_monitor,
on resource_monitors.tf line 1, in resource "snowflake_resource_monitor" "my_monitor":
1: resource "snowflake_resource_monitor" "my_monitor"
As temporary solution, destroy and recreate the RessourceMonitor works but you can loose Ressource Monitor current quota usage.
Hi all 👋 I'm currently working on the resource monitor as part of preparing GA objects for V1. As you already the root cause it's more of a Snowflake limitation rather than the provider one. When refactoring the resource monitor, I'll make sure it will be clearer on how to interact with the resource and apply the mentioned workarounds to make it work. The updated resource should be available in the v0.96.0 version of the provider, but I'll let you know here when it will be available.
Hey 👋 The new and refactored resource monitor was released yesterday in version 0.96.0 of the provider. Please migrate with migration guide and let me know if the issue has been resolved so we could close the ticket. Thanks in advance 🙏.
Provider Version
v0.55.0
Terraform Version
1.28
Describe the bug
The snowflake provider 0.55.0 allows for Resource Monitors to change the "credit_quota" argument without running a drop/create command. However, when changing the following arguments:
Expected behavior
Terraform apply will be successful.
Code samples and commands
The Resource Monitor resource, using a user assigned the accountadmin role:
resource "snowflake_resource_monitor" "resource_monitor" { name = "resource_monitor_test" credit_quota = 100 notify_triggers = [ 50 ] suspend_triggers = [ 100 ] suspend_immediate_triggers = [ 105 ] }
Changing "notify_trigger" argumentresource "snowflake_resource_monitor" "resource_monitor" { name = "resource_monitor_test" credit_quota = 100 notify_triggers = [ 55 ] suspend_triggers = [ 100 ] suspend_immediate_triggers = [ 105 ] }
Returns the following error message: │ 001003 (42000): SQL compilation error: │ syntax error line 1 at position 57 unexpected 'ON'. │ syntax error line 1 at position 72 unexpected 'DO'. │ syntax error line 1 at position 83 unexpected 'ON'. │ syntax error line 1 at position 98 unexpected 'DO'. │ syntax error line 1 at position 119 unexpected 'ON'. │ syntax error line 1 at position 133 unexpected 'DO'. │ syntax error line 1 at position 143 unexpected 'ON'. │ syntax error line 1 at position 157 unexpected 'DO'. │ syntax error line 1 at position 166 unexpected ''.
Additional context
Investigation into the compiled SnowSQL:
ALTER RESOURCE MONITOR "RESOURCE_MONITOR_TEST" SET TRIGGERS ON 100 PERCENT DO SUSPEND ON 105 PERCENT DO SUSPEND_IMMEDIATE ON 55 PERCENT DO NOTIFY ;
A possible solution, is to have the compiled SnowSQL to have the "credit_quota" present, even if the the argument has not changed:ALTER RESOURCE MONITOR "RESOURCE_MONITOR_TEST" SET CREDIT_QUOTA = 100 TRIGGERS ON 100 PERCENT DO SUSPEND ON 105 PERCENT DO SUSPEND_IMMEDIATE ON 55 PERCENT DO NOTIFY ;