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

Error message: Actual statement count 2 did not match the desired statement count 1

Open aroder opened this issue 4 years ago • 2 comments

Provider Version

The provider version you are using.

provider registry.terraform.io/chanzuckerberg/snowflake v0.22.0

Terraform Version

The version of Terraform you were using when the bug was encountered.

Terraform v1.0.0

Describe the bug

I have created a basic setup with some users, roles, and grants. When I try to remove them by changing their count to 0 and running terraform apply, I get the error message

Error: 000008 (0A000): Actual statement count 2 did not match the desired statement count 1

Expected behavior

I expect the resources to be deleted.

Code samples and commands The main.tf has a block that adds my snowflake module:

module "snowflake_instance" {
  source = "./modules/snowflake_instance"
  count = var.enable_snowflake_instance ? 1 : 0
  reader_users = var.reader_users
}

where reader_users is defined as

variable "reader_users" {
    type = set(string)
    default = []
}

with a value of

reader_users = ["jsmith"]

The snowflake module adds users, roles and grants such as the following:

resource snowflake_user reader_users {
  for_each = var.reader_users
  name = each.value
  comment = "A user with access to read the public schema in the dw database"
}
resource snowflake_role_grants reader_users_role_grants {
  for_each = var.reader_users
  role_name = snowflake_role.reporter.name
  users = [each.value]
}```

**Additional context**

Add any other context about the problem here.

aroder avatar Aug 17 '21 11:08 aroder

I can reproduce this issue anytime I change the list of roles in a grant. It appears that this forces a replacement, or a drop and then a create. This corroborates the message that there are 2 statements attempting to execute. I don't know if this is useful, but here is an example error message in this case:

image

image

aroder avatar Aug 17 '21 12:08 aroder

Having this issue while deployment on Snowflake using liquibase? Any solution?

abdoulsn avatar Jun 28 '22 12:06 abdoulsn

Hi, had this issue on Power bi while running a query on snowflake. Checked out the query history on snowflake and the error was highlighted with further details.

praveenkandasamy avatar Dec 05 '22 11:12 praveenkandasamy

We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.

sfc-gh-asawicki avatar Apr 30 '24 16:04 sfc-gh-asawicki