aidanmelen / terraform-provider-snowsql

Terraform SnowSQL provider
https://registry.terraform.io/providers/aidanmelen/snowsql/latest
Other
21 stars 10 forks source link

bug: Enters broken state when read statements are bad #78

Closed aidanmelen closed 1 year ago

aidanmelen commented 1 year ago

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "snowsql_exec" "role" {
  name = "my_role"

  create {...}

  read {
    # single quote is not closed 
    statements = "SHOW ROLES LIKE 'my_role; SHOW ROLES LIKE 'ACCOUNTADMIN';"
  }

  delete {...}
}

Panic Output

╷
│ Error: 001003 (42000): SQL compilation error:
│ syntax error line 1 at position 43 unexpected 'ACCOUNTADMIN'.
│ parse error line 1 at position 57 near '<EOF>'.
│ 
│   with snowsql_exec.role,
│   on main.tf line 1, in resource "snowsql_exec" "role":
│    1: resource "snowsql_exec" "role" {
│ 
╵ 

Expected Behavior

We should be able to fix the read statement and the updated read statement should be run on the next run.

Actual Behavior

Because the read statements are triggered during the read/refresh lifecycle, the old broken statements run before the new read statements are evaluated. The only way to fix is to manually update the terraform state.

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example: