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

Resource Monitor CREDIT_QUOTA type #145

Closed
dehume opened this issue Feb 25, 2020 · 3 comments · Fixed by #274
Closed

Resource Monitor CREDIT_QUOTA type #145

dehume opened this issue Feb 25, 2020 · 3 comments · Fixed by #274
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@dehume
Copy link

dehume commented Feb 25, 2020

I saw issue #109 about converting the credit quota from an int to a float in resource monitors but when I try and create a monitor I'm getting a data type error.

Error: error creating resource monitor EXAMPLE_MONITOR: 001008 (22023): SQL compilation error:
invalid value [5.00] for parameter 'CREDIT_QUOTA'

Using the generated SQL but using 5 instead of 5.00 creates the object successfully.

@Aaron-K-T-Berry
Copy link

Can confirm this is still an issue. Currently you are unable to create a resource monitor with credit quota other than 0 with all other values resulting in the above error. #111 seems suspect as the cause of this issue.

@ryanking ryanking added the bug Used to mark issues with provider's incorrect behavior label Mar 31, 2020
@ryanking ryanking self-assigned this Mar 31, 2020
@NJAldwin
Copy link

NJAldwin commented Apr 24, 2020

We are also running into this.

If I'm understanding the original issue #109 correctly, even though this parameter is an int, it is returned from Snowflake as a float? Seems likely that the fix for both issues would be to use an int for the parameter, but to accept a float back from snowflake?

@Aaron-K-T-Berry
Copy link

For anyone looking for a workaround to this problem in the mean time you can use a snowsql run via Terraform to update the credit quota after provisioning the resource monitor. Examples below.

locals {
  resource_monitor_name = "FOO_RESOURCE_MONITOR"
  credit_quote          = 100
  warehouse_name        = "FOO_WAREHOUSE"
}

resource "snowflake_resource_monitor" "resource_monitors" {
  lifecycle {
    ignore_changes = [
      # Ignore changes to credit quota as they are modified via a manual sql file
      credit_quota
    ]
  }

  name         = local.resource_monitor_name
  credit_quota = 0
}

resource "null_resource" "resource_monitor_credit_quotas" {
  depends_on = [snowflake_resource_monitor.resource_monitors]

  # Run the script every time apply is run
  triggers = {
    run_always = "${timestamp()}"
  }

  provisioner "local-exec" {
    command = "/usr/local/bin/snowsql -o variable_substitution=true  -f ${path.module}/update-quotas.sql --variable resource_monitor=${snowflake_resource_monitor.resource_monitors.name} --variable credit_quota=${local.credit_quote}"
  }
}

resource "snowflake_warehouse" "warehouses" {
  name             = local.warehouse_name
  resource_monitor = snowflake_resource_monitor.resource_monitors.name
}

And the update-quotas.sql looking something like.

ALTER RESOURCE MONITOR &resource_monitor SET CREDIT_QUOTA=&credit_quota;

ryanking pushed a commit that referenced this issue Oct 13, 2020
Snowflake only accepts credit_quota as an int.  However, the `show resource monitors` command returns it as a float.  This PR converts the float read from Snowflake into an int.  


## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested -->
* [x] acceptance tests
<!-- add more below if you think they are relevant -->

## References
Fixes #145 and #109
gjv9491 pushed a commit to gjv9491/terraform-provider-snowflake that referenced this issue Mar 19, 2021
Snowflake only accepts credit_quota as an int.  However, the `show resource monitors` command returns it as a float.  This PR converts the float read from Snowflake into an int.  


## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested -->
* [x] acceptance tests
<!-- add more below if you think they are relevant -->

## References
Fixes Snowflake-Labs#145 and Snowflake-Labs#109
anton-chekanov pushed a commit to anton-chekanov/terraform-provider-snowflake that referenced this issue Jan 25, 2022
Snowflake only accepts credit_quota as an int.  However, the `show resource monitors` command returns it as a float.  This PR converts the float read from Snowflake into an int.  


## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested -->
* [x] acceptance tests
<!-- add more below if you think they are relevant -->

## References
Fixes Snowflake-Labs#145 and Snowflake-Labs#109
daniepett pushed a commit to daniepett/terraform-provider-snowflake that referenced this issue Feb 9, 2022
Snowflake only accepts credit_quota as an int.  However, the `show resource monitors` command returns it as a float.  This PR converts the float read from Snowflake into an int.  


## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested -->
* [x] acceptance tests
<!-- add more below if you think they are relevant -->

## References
Fixes Snowflake-Labs#145 and Snowflake-Labs#109
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

Successfully merging a pull request may close this issue.

4 participants