Skip to content

Managed users are not removed from Projects when removed in terraform code #225

@cblomqvist

Description

@cblomqvist

Describe the bug

Provider version:

terraform {
  required_providers {
    project = {
      source  = "registry.terraform.io/jfrog/project"
      version = "1.9.5"
    }
  }
}

Adding a user to a custom role like this:

variable "role1_actions" {
  type    = list(string)
  default = ["READ_REPOSITORY"]
}

resource "project_environment" "myenv" {
  project_key = "my_lab"
  name        = "myenv"
}

resource "project_role" "role1" {
  project_key  = "my_lab"
  name         = "role1"
  type         = "CUSTOM"
  actions      = var.role1_actions
  environments = ["${project_environment.myenv.project_key}-${project_environment.myenv.name}"]
}

resource "project_user" "user1" {
  project_key = "my_lab"
  name        = "some_user"
  roles       = ["role1"]
}

Generates this block in terraform.tfstate:

{
    "mode": "managed",
    "type": "project_user",
    "name": "some_user",
    "provider": "provider[\"registry.terraform.io/jfrog/project\"]",
    "instances": [
    {
        "schema_version": 1,
        "attributes": {
        "id": "my_lab:some_user",
        "ignore_missing_user": false,
        "name": "some_user",
        "project_key": "my_lab",
        "roles": [
            "role1"
        ]
        },
        "sensitive_attributes": [],
        "identity_schema_version": 0
    }
    ]
}

If I remove the user, it is only removed from terraform.tfstate, not from the role in the Artifactory Project.

Also, every time I run terraform plan it reports that already existing users will be added again.

Requirements for an issue

  • A fully functioning terraform snippet that can be copy&pasted (no outside files or ENV vars unless that's part of the issue)
  • Your version of artifactory (you can curl it at $host/artifactory/api/system/version: JFrog Platform
    Enterprise Plus 7.117.7 rev 81707900
  • Your version of terraform: Tested with Terraform v1.13.4 and v1.14.1 on windows_amd64

Expected behavior
The other terraform Resources behaves as expected in that when I remove a resource from my terraform source code the resource is deleted in Artifactory.

Additional context

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