weixin_39637233
weixin_39637233
2020-12-25 17:08

rule creation leads to enabled rule, always

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:

hcl
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:
</computed></computed></computed>

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/terraform-provider-auth0

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39743357 weixin_39743357 4月前

    Hi , 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.

    点赞 评论 复制链接分享
  • weixin_39637233 weixin_39637233 4月前

    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",
    
    点赞 评论 复制链接分享
  • weixin_39743357 weixin_39743357 4月前

    Hi 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.

    点赞 评论 复制链接分享
  • weixin_39778106 weixin_39778106 4月前

    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.

    点赞 评论 复制链接分享

相关推荐