appoptics / terraform-provider-appoptics

Apache License 2.0
4 stars 2 forks source link

Error: Error applying plan - No error message provided #27

Closed sandnabba closed 4 years ago

sandnabba commented 4 years ago

I just tried applying a very simple appoptics_alert resource. Something failed, but I don't know why.

Resource:

resource "appoptics_alert" "http_5xx" {
  name        = "${var.alb_name}-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
  #description = "A Test Alert"
  services    = [156572]

  condition {
    type        = "above"
    threshold   = 10
    metric_name = "AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
    duration    = 600

    tag {
      name    = "awsaccount"
      grouped = true
      values  = ["tm-prod"]
    }
    tag {
      name    = "loadbalancer"
      grouped = true
      values  = ["*${var.alb_name}*"]
    }
  }
}

Output

emil@DvorakWork: ~/git/ops/sre-metrocard/estate/threatmonitor/terraform-templates/appoptics $> terraform apply

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.reg-api-alerts.appoptics_alert.http_5xx
      id:                                    <computed>
      active:                                "true"
      condition.#:                           "1"
      condition.3233007029.detect_reset:     ""
      condition.3233007029.duration:         "600"
      condition.3233007029.metric_name:      "AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
      condition.3233007029.summary_function: ""
      condition.3233007029.tag.#:            "2"
      condition.3233007029.tag.0.grouped:    "true"
      condition.3233007029.tag.0.name:       "awsaccount"
      condition.3233007029.tag.0.values.#:   "1"
      condition.3233007029.tag.0.values.0:   "tm-prod"
      condition.3233007029.tag.1.grouped:    "true"
      condition.3233007029.tag.1.name:       "loadbalancer"
      condition.3233007029.tag.1.values.#:   "1"
      condition.3233007029.tag.1.values.0:   "*reg-api*"
      condition.3233007029.threshold:        "10"
      condition.3233007029.type:             "above"
      name:                                  "reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
      rearm_seconds:                         "600"
      services.#:                            "1"
      services.3088397295:                   "156572"

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.reg-api-alerts.appoptics_alert.http_5xx: Creating...
  active:                                "" => "true"
  condition.#:                           "0" => "1"
  condition.3233007029.detect_reset:     "" => ""
  condition.3233007029.duration:         "" => "600"
  condition.3233007029.metric_name:      "" => "AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
  condition.3233007029.summary_function: "" => ""
  condition.3233007029.tag.#:            "0" => "2"
  condition.3233007029.tag.0.grouped:    "" => "true"
  condition.3233007029.tag.0.name:       "" => "awsaccount"
  condition.3233007029.tag.0.values.#:   "0" => "1"
  condition.3233007029.tag.0.values.0:   "" => "tm-prod"
  condition.3233007029.tag.1.grouped:    "" => "true"
  condition.3233007029.tag.1.name:       "" => "loadbalancer"
  condition.3233007029.tag.1.values.#:   "0" => "1"
  condition.3233007029.tag.1.values.0:   "" => "*reg-api*"
  condition.3233007029.threshold:        "" => "10"
  condition.3233007029.type:             "" => "above"
  name:                                  "" => "reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
  rearm_seconds:                         "" => "600"
  services.#:                            "0" => "1"
  services.3088397295:                   "" => "156572"

Error: Error applying plan:

1 error(s) occurred:

* module.reg-api-alerts.appoptics_alert.http_5xx: 1 error(s) occurred:

* appoptics_alert.http_5xx: Error creating AppOptics alert reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count: 

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

I'm not sure if this is a limitation in the provider or if it we are not getting any message from the AppOptics API.

sandnabba commented 4 years ago

Creation part with TF_LOG=TRACE:

module.reg-api-alerts.appoptics_alert.http_5xx: Creating...
  active:                                "" => "true"
  condition.#:                           "0" => "1"
  condition.3233007029.detect_reset:     "" => ""
  condition.3233007029.duration:         "" => "600"
  condition.3233007029.metric_name:      "" => "AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
  condition.3233007029.summary_function: "" => ""
  condition.3233007029.tag.#:            "0" => "2"
  condition.3233007029.tag.0.grouped:    "" => "true"
  condition.3233007029.tag.0.name:       "" => "awsaccount"
  condition.3233007029.tag.0.values.#:   "0" => "1"
  condition.3233007029.tag.0.values.0:   "" => "tm-prod"
  condition.3233007029.tag.1.grouped:    "" => "true"
  condition.3233007029.tag.1.name:       "" => "loadbalancer"
  condition.3233007029.tag.1.values.#:   "0" => "1"
  condition.3233007029.tag.1.values.0:   "" => "*reg-api*"
  condition.3233007029.threshold:        "" => "10"
  condition.3233007029.type:             "" => "above"
  name:                                  "" => "reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count"
  rearm_seconds:                         "" => "600"
  services.#:                            "0" => "1"
  services.3088397295:                   "" => "156572"
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalWriteState
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalApplyProvisioners
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalIf
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalWriteState
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalWriteDiff
2019/11/27 13:14:18 [TRACE] root.reg-api-alerts: eval: *terraform.EvalApplyPost
2019/11/27 13:14:18 [ERROR] root.reg-api-alerts: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* appoptics_alert.http_5xx: Error creating AppOptics alert reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count: 
2019/11/27 13:14:18 [ERROR] root.reg-api-alerts: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* appoptics_alert.http_5xx: Error creating AppOptics alert reg-api-AWS.ApplicationELB.HTTPCode_ELB_5XX_Count: 
2019/11/27 13:14:18 [TRACE] [walkApply] Exiting eval tree: module.reg-api-alerts.appoptics_alert.http_5xx
2019/11/27 13:14:18 [TRACE] dag/walk: upstream errored, not walking "provider.appoptics (close)"
2019/11/27 13:14:18 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2019/11/27 13:14:18 [TRACE] dag/walk: upstream errored, not walking "root"
2019/11/27 13:14:18 [TRACE] Preserving existing state lineage "a4d5e2c1-7415-47ba-abfd-33b7c8d1f104"
2019/11/27 13:14:18 [TRACE] Preserving existing state lineage "a4d5e2c1-7415-47ba-abfd-33b7c8d1f104"
2019/11/27 13:14:18 [TRACE] Preserving existing state lineage "a4d5e2c1-7415-47ba-abfd-33b7c8d1f104"
2019/11/27 13:14:18 [TRACE] Preserving existing state lineage "a4d5e2c1-7415-47ba-abfd-33b7c8d1f104"
2019/11/27 13:14:18 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-11-27T13:14:18.383+0100 [DEBUG] plugin.terraform-provider-appoptics: 2019/11/27 13:14:18 [ERR] plugin: plugin server: accept unix /tmp/plugin843405710: use of closed network connection

Error: Error applying plan:
sandnabba commented 4 years ago

Found out that the issue was that the service defined in the services = statement was invalid.

Would still be nice with a proper error message however. :)

solarchad commented 4 years ago

Thanks for going through this. This is a valid problem and I believe I ran into it as well. Errors that we'd expect from the client library don't seem to be making it into the Terraform output with the plugin.

solarchad commented 4 years ago

I think this issue may also be due to something with the SDK/client. I mentioned this in the issue I created here: https://github.com/appoptics/appoptics-api-go/issues/69