terraform-provider-opsgenie icon indicating copy to clipboard operation
terraform-provider-opsgenie copied to clipboard

Impossible to create api integrations of type email with the provider

Open RubenVosmeer opened this issue 3 years ago • 1 comments

Hi,

Using the provider, it is impossible to create an api integration of type Email.

Terraform Version

  • Terraform v0.14.8
  • provider.opsgenie v0.6.0

Affected Resource(s)

  • opsgenie_api_integration

Terraform Configuration Files

 resource "opsgenie_api_integration" "email" {
   name = "email integration of team X"
   owner_team_id = opsgenie_team.team.id
   type = "Email"
   emailUsername = "X"
 }

Debug Output

With omission of emailUsername

Error: Error occurred with Status code: 422, Message: Request body is not processable. Please check the errors., Took: 0.001000, RequestId: a1304fce-6ecd-40d5-ac90-25179867fa26, Error Detail: map[emailUsername:must not be blank]

  on ../opsgenie_team/team.tf line 19, in resource "opsgenie_api_integration" "email":
  19: resource "opsgenie_api_integration" "email" {

With inclusion of emailUsername

Error: Unsupported argument

  on ../opsgenie_team/team.tf line 23, in resource "opsgenie_api_integration" "email":
  23:   emailUsername = var.team_name

An argument named "emailUsername" is not expected here.

Expected Behavior

Creation of an API integration of type email on team level.

Actual Behavior

  • When emailUsername is not included, the plan is successful, and the error occurs when being applied, while api calls are performed. The deployment fails and no api integration is created.
  • When emailUsername is included, the plan fails.

Steps to Reproduce

  1. terraform apply

Important Factoids

  • It seems the Opsgenie api requires emailUsername in the request for integration of type Email (https://docs.opsgenie.com/docs/integration-api#create-email-based-integration)
  • emailUsername is not defined as an accepted input in resource_opsgenie_api_integration.go
  • Integrations of type email is processed together with all other integrations (except webhooks), using standard parameters, and therefore missing the required parameter when calling the opsgenie api: https://github.com/opsgenie/terraform-provider-opsgenie/blob/d98b6d4acdda83a15e6be2e1be8a48d5c75ea01f/opsgenie/resource_opsgenie_api_integration.go#L97
  • possibly might benefit from adding another method similar to createWebhookIntegration that allows the additional parameter, complying with the opsgenie API.

References

  • similar to #176

RubenVosmeer avatar Jun 16 '21 17:06 RubenVosmeer

Hi! You need to create opsgenie_email_integration resource instead. Here is the doc for that: https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs/resources/email_integration

Sergey-Kirgizov avatar Jul 04 '21 07:07 Sergey-Kirgizov