opsgenie / terraform-provider-opsgenie

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

Team will not updated in existing OpsGenie Service #216

Open 0x46616c6b opened 3 years ago

0x46616c6b commented 3 years ago

Hello,

we run the latest version of the provider (v0.5.7) and try to adjust the resource opsgenie_service and want to change the team_id. In every plan and run the output brings changes to the resources but after successful run the origin is not adjusted.

Terraform Version

0.14.3

Affected Resource(s)

Terraform Configuration Files

resource "opsgenie_team" "team_one" {
  name = "Team One"
}

resource "opsgenie_team" "team_two" {
  name = "Team two"
}

resource "opsgenie_service" "service_name" {
  name        = "Service"
  team_id     = opsgenie_team_one.team.id
  description = "Example Team"
}

Expected Behavior

When I change the team_id property I expected that the team will changed.

Actual Behavior

The old team is not replaced with the new one.

Steps to Reproduce

  1. Apply this config (two teams and one service)

    resource "opsgenie_team" "team_one" {
      name = "Team One"
    }
    
    resource "opsgenie_team" "team_two" {
      name = "Team two"
    }
    
    resource "opsgenie_service" "service_name" {
      name        = "Service"
      team_id     = opsgenie_team_one.team.id
      description = "Example Team"
    }
  2. Apply with changed team_id

    resource "opsgenie_team" "team_one" {
      name = "Team One"
    }
    
    resource "opsgenie_team" "team_two" {
      name = "Team two"
    }
    
    resource "opsgenie_service" "service_name" {
      name        = "Service"
      team_id     = opsgenie_team_two.team.id
      description = "Example Team"
    }
  3. You will see that still Team One is connected with the service.

0x46616c6b commented 3 years ago

https://github.com/opsgenie/terraform-provider-opsgenie/blob/6f098f5469224f725f6894a90f3b6a1496ba803f/opsgenie/resource_opsgenie_service.go#L97-L106

Seems that the team never read from the update request.

liamkinne commented 2 years ago

Hey Opsgenie team, is this going to be fixed soon?

NickAdolf commented 1 year ago

The API behind this request doesn't accept team at this point-->

https://docs.opsgenie.com/docs/service-api#update-service

oeuftete commented 1 week ago

The API behind this request doesn't accept team at this point-->

https://docs.opsgenie.com/docs/service-api#update-service

This still appears to be true.


Example workaround (which can be simpler if your team id comes from a resource):

resource "terraform_data" "opsgenie-team-id" {
  input = var.opsgenie_team_id
}

resource "opsgenie_service" "service" {
  name        = var.name
  description = var.description
  team_id     = terraform_data.opsgenie-team-id.output

  # Services do not appear to register changes to team IDs.
  # See https://github.com/opsgenie/terraform-provider-opsgenie/issues/216,
  # others.
  lifecycle {
    replace_triggered_by = [
      terraform_data.opsgenie-team-id
    ]
  }
}