Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to create elasticsearch_kibana_alert - Root resource was present, but now absent. #315

Open
sparrowt opened this issue Sep 26, 2022 · 0 comments

Comments

@sparrowt
Copy link

sparrowt commented Sep 26, 2022

Error

Trying to create a elasticsearch_kibana_alert resource results in the following error:

Acquiring state lock. This may take a few moments...
elasticsearch_kibana_alert.my-test-alert-from-tf: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ elasticsearch_kibana_alert.my-test-alert-from-tf, provider
│ "provider[\"registry.terraform.io/phillbaker/elasticsearch\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
Releasing state lock. This may take a few moments...
time=2022-09-26T17:17:36+01:00 level=error msg=1 error occurred:
        * exit status 1

Environment

  • terraform v1.0.2
  • phillbaker/elasticsearch v2.0.4
  • elasticsearch & kibana both at version 7.17.1 (elastic.co hosted)

Repro

I was originally trying this with an anomaly detection alert, but it also repros with a simple log threshold - example Terraform:

resource "elasticsearch_kibana_alert" "my-test-alert-from-tf" {
 name = "my-test-alert-from-tf"
  schedule {
    interval = "10m"
  }
  consumer = "alerts"
  alert_type_id = "logs.alert.document.count"
  enabled = true
  params_json = <<EOF
{
    "timeSize": 5,
    "timeUnit": "m",
    "count": {
        "value": 1000,
        "comparator": "more than"
    },
    "criteria": [
        {
            "field": "log.level.keyword",
            "comparator": "equals",
            "value": "ERROR"
        }
    ]
}
EOF
  notify_when = "onActionGroupChange"
  actions {
    action_type_id = ".email"
    id = "elastic-cloud-email"
    group = "logs.threshold.fired"
    params = {
      message = "Too many ERROR log lines, uh oh"
      to = "recipient@example.com"
      subject = "Test alert from dev ELK stack"
    }
  }
}

In case it's relevant, under the provider "elasticsearch" block I have set kibana_url to the same value as url (as I'm not sure what else to set it to) - both URLs are of the form https://RANDOMNESS.us-east-1.aws.found.io:9243 which is where I access the Kibana UI.

https://www.reddit.com/r/Terraform/comments/m5nv14/comment/gr29zct/ suggests that this kind of error Root resource was present, but now absent means the provider is returning null from the apply, despite having planned to create something (?) I tried with TF_LOG=INFO (see collapsed output below) but that doesn't enlighten me any further unfortunately.

Expand for full output with TF_LOG=INFO
2022-09-26T16:04:40.638+0100 [INFO]  Terraform version: 1.0.2
2022-09-26T16:04:40.639+0100 [INFO]  Go runtime version: go1.16.4
2022-09-26T16:04:40.639+0100 [INFO]  CLI args: []string{"C:\\ProgramData\\chocolatey\\lib\\terraform\\tools\\terraform.exe", "apply", "tfplan"}
2022-09-26T16:04:40.645+0100 [INFO]  CLI command args: []string{"apply", "tfplan"}
2022-09-26T16:04:40.669+0100 [INFO]  AWS Auth provider used: "EnvProvider"
2022-09-26T16:04:41.772+0100 [INFO]  Failed to read plugin lock file .terraform\plugins\windows_amd64\lock.json: open .terraform\plugins\windows_amd64\lock.json: The system cannot find the path specified.
2022-09-26T16:04:41.773+0100 [INFO]  backend/local: starting Apply operation
Acquiring state lock. This may take a few moments...
2022-09-26T16:04:44.056+0100 [INFO]  provider: configuring client automatic mTLS
2022-09-26T16:04:44.143+0100 [INFO]  provider.terraform-provider-aws_v3.49.0_x5.exe: configuring server automatic mTLS: timestamp=2022-09-26T16:04:44.142+0100
2022-09-26T16:04:44.327+0100 [INFO]  provider: configuring client automatic mTLS
2022-09-26T16:04:44.384+0100 [INFO]  provider.terraform-provider-elasticsearch_v2.0.4.exe: configuring server automatic mTLS: timestamp=2022-09-26T16:04:44.383+0100
2022-09-26T16:04:44.461+0100 [INFO]  backend/local: apply calling Apply
2022-09-26T16:04:44.461+0100 [INFO]  terraform: building graph: GraphTypeApply
2022-09-26T16:04:44.466+0100 [INFO]  ReferenceTransformer: reference not found: "path.module"
2022-09-26T16:04:44.466+0100 [INFO]  ReferenceTransformer: reference not found: "path.module"
2022-09-26T16:04:44.467+0100 [INFO]  ReferenceTransformer: reference not found: "path.module"
2022-09-26T16:04:44.470+0100 [INFO]  provider: configuring client automatic mTLS
2022-09-26T16:04:44.527+0100 [INFO]  provider.terraform-provider-elasticsearch_v2.0.4.exe: configuring server automatic mTLS: timestamp=2022-09-26T16:04:44.526+0100
2022-09-26T16:04:44.584+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/phillbaker/elasticsearch\"]" changed the config value, but that value is unused
elasticsearch_kibana_alert.my-test-alert-from-tf: Creating...
2022-09-26T16:04:44.590+0100 [INFO]  Starting apply for elasticsearch_kibana_alert.my-test-alert-from-tf
2022-09-26T16:04:45.058+0100 [INFO]  provider.terraform-provider-elasticsearch_v2.0.4.exe: 2022/09/26 16:04:45 [INFO] Pinging url to determine version https://REDACTED.us-east-1.aws.found.io:9243 with timeout 5s: timestamp=2022-09-26T16:04:45.058+0100
2022-09-26T16:04:45.162+0100 [INFO]  provider.terraform-provider-elasticsearch_v2.0.4.exe: 2022/09/26 16:04:45 [INFO] ES version {Number:7.17.1 BuildFlavor:default BuildType:docker BuildHash:e5acb99f822233d62d6444ce45a4543dc1c8059a BuildDate:2022-02-23T22:20:54.153567231Z BuildSnapshot:false LuceneVersion:8.11.1 MinimumWireCompatibilityVersion:6.8.0 MinimumIndexCompatibilityVersion:6.0.0-beta1}: timestamp=2022-09-26T16:04:45.162+0100
2022-09-26T16:04:46.346+0100 [INFO]  provider.terraform-provider-elasticsearch_v2.0.4.exe: 2022/09/26 16:04:46 [INFO] Kibana Alert () created: timestamp=2022-09-26T16:04:46.346+0100
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ elasticsearch_kibana_alert.my-test-alert-from-tf, provider
│ "provider[\"registry.terraform.io/phillbaker/elasticsearch\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
Releasing state lock. This may take a few moments...
time=2022-09-26T16:04:48+01:00 level=error msg=1 error occurred:
        * exit status 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant