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

Updating Targets in a Target Group Forces Replacement #1088

Open
rigualj opened this issue Oct 8, 2024 · 0 comments
Open

Updating Targets in a Target Group Forces Replacement #1088

rigualj opened this issue Oct 8, 2024 · 0 comments

Comments

@rigualj
Copy link

rigualj commented Oct 8, 2024

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.5.4

Affected Resource(s)

harness_platform_feature_flag_target_group

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "harness_platform_feature_flag_target_group" "target" {
  for_each        = local.feature_flag_target_groups_map

  account_id      = var.harness_account_id
  org_id          = var.organization_id
  project_id      = var.project_id
  environment     = each.value.environment_id
  identifier      = each.value.target_group_id
  name            = each.value.target_group_name
  included        = each.value.included
  excluded        = each.value.excluded
  rule {
    attribute = "MY_ATTRIBUTE"
    op        = "equal"
    values    = ["MY_VALUE"]
  }
}

Debug Output

Behavior Issue

Panic Output

Expected Behavior

Targets get updated without replacing Target Group. This should mimic the behavior in the Harness API, which supports a PATCH in-place. https://apidocs.harness.io/tag/Target-Groups#operation/PatchSegment

Actual Behavior

Terraform Provider performs a require replacement = true.

Steps to Reproduce

  1. Create a feature flag (does not need to be done by Terraform)
  2. Create targets (preferred to do this by Terraform)
  3. Create target groups and add targets to either the include list or exclude list (must be done by Terraform)
  4. Link the target group to a feature flag (Can be done by GUI)
  5. Update target group via Terraform to remove or add targets to the existing Target Group

Important Factoids

Terraform forces a replacement of the target group. This fails because you cannot delete a Target Group if it's linked to a feature flag.

The current workaround is to use the Harness API to PATCH the target group with updates to the include or exclude list.

References

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