opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
103 stars 137 forks source link

opsgenie_api_integration - Status code: 404, Message: No handler found #380

Closed slushysnowman closed 1 year ago

slushysnowman commented 1 year ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v1.4.4 on linux_amd64

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

provider "opsgenie" {
  api_key = "APIKEY"
  api_url = "api.eu.opsgenie.com"
}

resource "opsgenie_api_integration" "test_prom" {
  name = "test_prom"
  type = "API"
}

Expected Behavior

API integration should have been created

Actual Behavior

│ Error: Error occurred with Status code: 404, Message: No handler found, Took: 0.002000, RequestId: ed33bc20-b834-4d84-91fc-f03209f95796

Steps to Reproduce

  1. Copy paste code above
  2. Add your API key to provider config
  3. Terraform apply

Important Factoids

I saw some other issue mentioning that the EU api url might be the cause, but that is not documented anywhere.

hadoken69 commented 1 year ago

I've got the same issue. It's also not working with "opsgenie_api_integration" and type="Webhook"

arjunrajpal commented 1 year ago

Hey @slushysnowman and @hadoken69 , I tried creating the below resource in an EU Opsgenie site and it worked fine. I have pasted the logs as well.

resource "opsgenie_api_integration" "test_prom" {
  name = "test_prom"
  type = "API"
}
terraform apply -target "opsgenie_api_integration.test_prom"                   

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:

  # opsgenie_api_integration.test_prom will be created
  + resource "opsgenie_api_integration" "test_prom" {
      + allow_write_access = true
      + api_key            = (sensitive value)
      + enabled            = true
      + id                 = (known after apply)
      + name               = "test_prom"
      + type               = "API"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
╵

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

opsgenie_api_integration.test_prom: Creating...
opsgenie_api_integration.test_prom: Creation complete after 2s [id=da2f617e-83ea-4847-9584-818575e504c5]
╷
│ Warning: Applied changes may be incomplete
│ 
│ The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be fully updated. Run the following command to verify that no other
│ changes are pending:
│     terraform plan
│       
│ Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error
│ message.
╵

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
hadoken69 commented 1 year ago

@arjunrajpal this worked for you but I've still got the issue Terraform v1.5.0

provider "opsgenie" {
  api_key = var.opsgenie_admin_api_key
  api_url = "api.eu.opsgenie.com"
}
terraform {
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 4.67.0"
    }
    opsgenie = {
      source  = "opsgenie/opsgenie"
      version = "~> 0.6.24"
    }
  }
}
resource "opsgenie_api_integration" "webhook-exports" {
  name = "CND_-_Exports ${upper(var.env)} Webhook"
  type = "Webhook"

  responders {
    type = "team"
    id   = "9d2b7217-0ff5-4607-848c-133c2e54f37d"
  }
  enabled                = false
  allow_write_access     = false
  suppress_notifications = true
  webhook_url            = google_cloudfunctions2_function.gcf_opsgenie_connector.service_config[0].uri
  headers = {
    Authorization = var.opsgenie_webhook_secret
  }
}

Log plan : Terraform will perform the following actions:

  # opsgenie_api_integration.webhook-exports will be created
  + resource "opsgenie_api_integration" "webhook-exports" {
      + allow_write_access     = false
      + api_key                = (sensitive value)
      + enabled                = false
      + headers                = {
          + "Authorization" = "********************" # Masked on purpose
        }
      + id                     = (known after apply)
      + name                   = "CND_-_Exports DEV Webhook"
      + suppress_notifications = true
      + type                   = "Webhook"
      + webhook_url            = "************************" # Masked on purpose

      + responders {
          + id   = "9d2b7217-0ff5-4607-848c-133c2e54f37d"
          + type = "team"
        }
    }

Apply : │ Error: Error occurred with Status code: 404, Message: No handler found, Took: 0.027000, RequestId: 77b3a134-c8c4-4bfb-9095-fd19f14680a2 │ │ with opsgenie_api_integration.webhook-exports, │ on opsgenie.tf line 3, in resource "opsgenie_api_integration" "webhook-exports": │ 3: resource "opsgenie_api_integration" "webhook-exports" { │ ╵

I've tried to activate more logs with TF_LOG=TRACE but i've not found more clues than this message

arjunrajpal commented 1 year ago

Hey @slushysnowman / @hadoken69 , can you please raise a ticket at https://support.atlassian.com/contact/#/ so that we can investigate this in greater detail ? We would need some more information around your Opsgenie site to look into this further.

kstevensonnv commented 1 year ago

Confirming fix from https://github.com/opsgenie/terraform-provider-opsgenie/issues/303#issuecomment-1139705737, changing the api_url on the provider from api.eu.opsgenie.com to api.opsgenie.com works.

data "opsgenie_team" "infrastructure" {
  name = "Infrastructure"
}

resource "opsgenie_api_integration" "organization_cloudtrail_cis_benchmark" {
  name                           = "organization-cloudtrail-cis-benchmark"
  type                           = "AmazonSns"

  owner_team_id                  = data.opsgenie_team.infrastructure.id
  enabled                        = false
  ignore_responders_from_payload = true
}
Error: Error occurred with Status code: 404, Message: No handler found, Took: 0.002000, RequestId: x
│ 
│   with opsgenie_api_integration.organization_cloudtrail_cis_benchmark,
│   on opsgenie.tf line 5, in resource "opsgenie_api_integration" "organization_cloudtrail_cis_benchmark":
│    5: resource "opsgenie_api_integration" "organization_cloudtrail_cis_benchmark" {

Obviously not fixed and reading through other issues it is clear the aim is to close rather than fix.