Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

rule creation leads to enabled rule, always #75

Closed
jasonkuhrt opened this issue Jan 23, 2019 · 4 comments
Closed

rule creation leads to enabled rule, always #75

jasonkuhrt opened this issue Jan 23, 2019 · 4 comments
Labels
bug Something isn't working stale tf-has-change-bug

Comments

@jasonkuhrt
Copy link

Direct API call such as the following does the right thing:

curl -X POST \
  "https://$TENANT.auth0.com/api/v2/rules" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "name":    "rule-test",
    "script":  "exports.rule = function (user, context, callback) {\n  console.log({\n    user: user,\n    context: context\n  })\n  return callback(null, user, context);\n}\n",
    "enabled": false
}'

However using this terraform provider does not:

resource "auth0_rule" "terraform-test" {
  name    = "terraform-test"
  script  = "${file("${path.module}/rules/terraform-test.js")}"
  enabled = false
}
❯ terraform apply
REDACTED OUTPUT

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + module.auth0-infra.auth0_rule.terraform-test
      id:      <computed>
      enabled: "false"
      name:    "terraform-test"
      order:   <computed>
      script:  "exports.rule = function (user, context, callback) {\n  console.log({\n    user: user,\n    context: context\n  })\n  return callback(null, user, context);\n}\n"


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

module.auth0-infra.auth0_rule.terraform-test: Creating...
  enabled: "" => "false"
  name:    "" => "terraform-test"
  order:   "" => "<computed>"
  script:  "" => "exports.rule = function (user, context, callback) {\n  console.log({\n    user: user,\n    context: context\n  })\n  return callback(null, user, context);\n}\n"
module.auth0-infra.auth0_rule.terraform-test: Creation complete after 1s (ID: REDACTED)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.


❯ terraform apply
REDACTED OUTPUT

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ module.auth0-infra.auth0_rule.terraform-test
      enabled: "true" => "false"


Plan: 0 to add, 1 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:

The immediate second apply is demonstrates the bug.

I would love to see the raw underlying http request being sent by this provider but it being https traffic I didn't find a trivial way to sniff it (ngrep, tcpdump, etc.).

@alexkappa
Copy link
Owner

Hi @jasonkuhrt, you could print debug information by running apply with the following env vars.

TF_LOG=DEBUG AUTH0_DEBUG=1 terraform apply

This should help diagnose the underlying http requests.

@jasonkuhrt
Copy link
Author

Results, filtered for searching for keyword enabled

module.auth0-infra.auth0_rule.terraform-test: Creating...
  enabled: "" => "false"

Starts to go wrong here:

2019-01-28T09:03:36.137-0500 [DEBUG] plugin.terraform-provider-auth0_v0.1.12: {"id":"rul_agpLc8RSaA7rj2RF","enabled":true,"script":"exports.rule = function (user, context, callback) {\n  console.log({\n    user: user,\n    context: context\n  })\n  return callback(null, user, context);\n}\n","name":"terraform-test-patched","order":9,"stage":"login_success"}
2019-01-28T09:03:36.241-0500 [DEBUG] plugin.terraform-provider-auth0_v0.1.12: {"id":"rul_agpLc8RSaA7rj2RF","enabled":true,"script":"exports.rule = function (user, context, callback) {\n  console.log({\n    user: user,\n    context: context\n  })\n  return callback(null, user, context);\n}\n","name":"terraform-test-patched","order":9,"stage":"login_success"}
                "auth0_rule.terraform-test": {
                    "type": "auth0_rule",
                    "depends_on": [],
                    "primary": {
                        "id": "rul_agpLc8RSaA7rj2RF",
                        "attributes": {
                            "enabled": "true",

@alexkappa
Copy link
Owner

Hi @jasonkuhrt I am able to reproduce the error quite consistently, but I haven't quite figured out how to fix it yet. I'll update once I make some progress.

@alexkappa alexkappa added bug Something isn't working tf-has-change-bug labels Mar 27, 2019
laurentdutheil pushed a commit to laurentdutheil/terraform-provider-auth0 that referenced this issue Aug 27, 2019
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity.
Stale issues will be closed after 5 days if no action is taken. If you
think this issue should not be closed, remove the stale label.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working stale tf-has-change-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants