Skip to content

project_environment creation fails if more than one project_environment is slated to be created. #184

@richardmcsong

Description

@richardmcsong

Given:

locals {
  envs = toset(["CUSTOM-REMOTE", "CUSTOM-ENV"])
}

resource "project" "tenant" {
  key          = "projkey"
  display_name = "projkey"
  admin_privileges {
    index_resources  = false
    manage_members   = false
    manage_resources = false
  }
}

resource "project_environment" "env" {
  for_each    = toset(var.environments)
  name        = each.key
  project_key = project.tenant.key
}

Running this, there's a race condition that happens between CUSTOM-REMOTE and
CUSTOM-ENV. Given that CUSTOM-ENV successfully gets created, we get the
following error:

Error: Unable to Create Resource

[...]

An unexpected error occurred while creating the resource update request.
Please report this issue to the provider developers.

Error: BAD_REQUEST - Project Admin should contain all global and project
environments. Project environments: [PROD, DEV, projkey-CUSTOM-REMOTE,
projkey-CUSTOM-ENV] but got: [PROD, DEV, projkey-CUSTOM-REMOTE]

CUSTOM-ENV then gets stuck in a tainted state. Any further operations results in:

  ╷
  │ Error: Unable to Delete Resource
  │ 
  │ An unexpected error occurred while attempting to delete the resource.
  │ Please retry the operation or report this issue to the provider developers.
  │ 
  │ Error: NOT_FOUND - Could not find environment `projkey-CUSTOM-REMOTE`
  ╵

Key info:

  Terraform v1.8.4
  on darwin_arm64

provider: 1.9.0
artifactory version: Enterprise Plus 7.90.15

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions