onelogin / terraform-provider-onelogin

GNU General Public License v3.0
27 stars 19 forks source link

error - Missing required action attribute when running terraform apply #64

Closed dlethin closed 3 years ago

dlethin commented 3 years ago

I picked up v0.1.20 and while it solves the problem of importing app_rules, there seems to have been a regression as I'm getting an error when I try to create a new app rule. The terraform apply works in v0.1.19

Here's my test project:

resource "onelogin_app_rules" "example" {
  app_id   = NNNNN
  #position = 10
  enabled  = true
  match    = "all"
  name     = "terraform-test"
  conditions {
    operator = "="
    source   = "email"
    value    = "me@mycompany.com"

  }
  actions {
    action = "set_role_from_existing"
    value = [
      "arn:aws:iam::XXXXX:role/myrole"
    )
  }
}

Here's the run of terraform apply showing the error:

✗ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # onelogin_app_rules.example will be created
  + resource "onelogin_app_rules" "example" {
      + app_id   = "NNNNN"
      + enabled  = true
      + id       = (known after apply)
      + match    = "all"
      + name     = "terraform-test"
      + position = (known after apply)

      + actions {
          + action = "set_role_from_existing"
          + value  = [
              + "arn:aws:iam::XXXXX:role/myrole",
            ]
        }

      + conditions {
          + operator = "="
          + source   = "email"
          + value    = "me@mycompany.com"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

onelogin_app_rules.example: Creating...
╷
│ Error: error: context: [ol http service], error_message: [{"code":422,"message":"Validation Failed","errors":[{"field":"actions","message":["Missing required action attribute"]}]}]
│
│   with onelogin_app_rules.example,
│   on onelogin.tf line 47, in resource "onelogin_app_rules" "example":
│   47: resource "onelogin_app_rules" "example" {
│
╵

Here's the terraform version info:

✗ terraform version
Terraform v0.15.3
on darwin_amd64
+ provider registry.terraform.io/onelogin/onelogin v0.1.20

Your version of Terraform is out of date! The latest version
is 1.0.0. You can update by downloading from https://www.terraform.io/downloads.html

Looks like there are some additional changes beyond the enhancement to app_rule imports --

https://github.com/onelogin/terraform-provider-onelogin/compare/v0.1.19...v0.1.20?w=1

Is this change causing issues? -- https://github.com/onelogin/terraform-provider-onelogin/pull/61/files

dcaponi commented 3 years ago

Weird, it was working for the person who submitted the PR. I can reproduce this too so I'll have to see what the problem is. I did add some better logging too so that should also be coming out with the fix for this.

dlethin commented 3 years ago

I created and built a local copy of the provider using make sidecar ( I had to tinker a bit with that Makefile) and confirmed that if I undo that specific change, my apply works. Would be interesting to see what your logging shows. This would be where having TF_LOG=true dump the API request/response would be helpful to see what's different.

dcaponi commented 3 years ago

@dlethin I just had this working locally and pushed a hotfix. Check out v0.1.23 as soon as its published to the registry. should be up in a few minutes

dlethin commented 3 years ago

Just tried out v0.1.23 and works for both importing resources and applying new ones. I will close this one out. Thanks again.