HarperDB-Add-Ons / terraform-provider-harperdb

Mozilla Public License 2.0
3 stars 0 forks source link

Error creating a role using the Terraform provider #3

Open gordonmurray opened 1 year ago

gordonmurray commented 1 year ago

When creating a role using Terraform, I use the following:

resource "harperdb_role" "movies_read" {
  name = "movies_read"
  schema_permissions = {
    imdb = {
      tables = {
        "movies" = {
          read = true
          delete = true
          attribute_permissions = [
            {
              name = "attributed"
              read = false
            }
          ]
        }
      }
    }
  }
}

In this case, the 'movies' schema exists.

When I run a terraform apply, I get an error of:

harperdb_role.movies_read: Creating...
╷
│ Error: Client Error
│ 
│   with harperdb_role.movies_read,
│   on roles.tf line 1, in resource "harperdb_role" "movies_read":
│    1: resource "harperdb_role" "movies_read" {
│ 
│ Unable to create role, got error: json: cannot unmarshal number 1683110017643.3918 into Go struct field Role.__updatedtime__ of type harperdb.Timestamp (200) !! <nil>
╵

The role is created but not persisted in the state file. So the next apply will try to create the role again and fail with an error of:

│ Unable to create role, got error: {"error":"A role with name 'movies_read' already exists"} (409) !!

moredhel commented 1 year ago

Hi @gordonmurray,

Strange, I didn't come across this issue when developing it. I'm having a look at it now. I'll let you know what I find.

moredhel commented 1 year ago

I've updated the underlying go library and pushed an update for the Terraform Provider. Let me know if that works for you.