Skip to content

platform_global_role.actions seemingly does not support all allowed valuwes #332

Description

@kingcrunch

Describe the bug

I try to import pre-defined roles into terraform, for example Viewer

import {
  id = "Viewer"
  to = platform_global_role.viewer
}
resource "platform_global_role" "viewer" {
  name         = "Viewer"
  description  = "Viewer Role"
  type         = "PREDEFINED"
  environments = ["DEV"]
  actions = [
    "READ_APPLICATION",
    "READ_APPLICATION_VERSION",
    "READ_APPTRUST_POLICY",
    "READ_BUILD",
    "READ_INTEGRATIONS_PIPELINE",
    "READ_POOLS_PIPELINE",
    "READ_RELEASE_BUNDLE",
    "READ_REPOSITORY",
    "READ_SOURCES_PIPELINE",
  ]
}

The list of actions is taken from the list, which terraform shows as change, when one try to set an empty list (e.g. actions = []). The error

$ terraform plan -target=platform_global_role.viewer
╷
│ Error: Invalid Attribute Value Match
│
│   with platform_global_role.viewer,
│   on predefined.tf line 81, in resource "platform_global_role" "viewer":
│   81:   actions = [
│   82:     "READ_APPLICATION",
│   83:     "READ_APPLICATION_VERSION",
│   84:     "READ_APPTRUST_POLICY",
│   85:     "READ_BUILD",
│   86:     "READ_INTEGRATIONS_PIPELINE",
│   87:     "READ_POOLS_PIPELINE",
│   88:     "READ_RELEASE_BUNDLE",
│   89:     "READ_REPOSITORY",
│   90:     "READ_SOURCES_PIPELINE",
│   91:   ]
│
│ Attribute actions[Value("READ_APPLICATION")] value must be one of: ["READ_REPOSITORY" "ANNOTATE_REPOSITORY" "DEPLOY_CACHE_REPOSITORY" "DELETE_OVERWRITE_REPOSITORY""MANAGE_XRAY_MD_REPOSITORY" "READ_RELEASE_BUNDLE" "ANNOTATE_RELEASE_BUNDLE" "CREATE_RELEASE_BUNDLE" "DISTRIBUTE_RELEASE_BUNDLE" "DELETE_RELEASE_BUNDLE" "MANAGE_XRAY_MD_RELEASE_BUNDLE""READ_BUILD" "ANNOTATE_BUILD" "DEPLOY_BUILD" "DELETE_BUILD" "MANAGE_XRAY_MD_BUILD" "READ_SOURCES_PIPELINE" "TRIGGER_PIPELINE" "READ_INTEGRATIONS_PIPELINE" "READ_POOLS_PIPELINE""REPORTS_SECURITY" "WATCHES_SECURITY" "POLICIES_SECURITY" "RULES_SECURITY" "READ_POLICIES_SECURITY"], got: "READ_APPLICATION"
╵
╷
│ Error: Invalid Attribute Value Match
│
│   with platform_global_role.viewer,
│   on predefined.tf line 81, in resource "platform_global_role" "viewer":
│   81:   actions = [
│   82:     "READ_APPLICATION",
│   83:     "READ_APPLICATION_VERSION",
│   84:     "READ_APPTRUST_POLICY",
│   85:     "READ_BUILD",
│   86:     "READ_INTEGRATIONS_PIPELINE",
│   87:     "READ_POOLS_PIPELINE",
│   88:     "READ_RELEASE_BUNDLE",
│   89:     "READ_REPOSITORY",
│   90:     "READ_SOURCES_PIPELINE",
│   91:   ]
│
│ Attribute actions[Value("READ_APPLICATION_VERSION")] value must be one of: ["READ_REPOSITORY" "ANNOTATE_REPOSITORY" "DEPLOY_CACHE_REPOSITORY" "DELETE_OVERWRITE_REPOSITORY""MANAGE_XRAY_MD_REPOSITORY" "READ_RELEASE_BUNDLE" "ANNOTATE_RELEASE_BUNDLE" "CREATE_RELEASE_BUNDLE" "DISTRIBUTE_RELEASE_BUNDLE" "DELETE_RELEASE_BUNDLE" "MANAGE_XRAY_MD_RELEASE_BUNDLE""READ_BUILD" "ANNOTATE_BUILD" "DEPLOY_BUILD" "DELETE_BUILD" "MANAGE_XRAY_MD_BUILD" "READ_SOURCES_PIPELINE" "TRIGGER_PIPELINE" "READ_INTEGRATIONS_PIPELINE" "READ_POOLS_PIPELINE""REPORTS_SECURITY" "WATCHES_SECURITY" "POLICIES_SECURITY" "RULES_SECURITY" "READ_POLICIES_SECURITY"], got: "READ_APPLICATION_VERSION"
╵
╷
│ Error: Invalid Attribute Value Match
│
│   with platform_global_role.viewer,
│   on predefined.tf line 81, in resource "platform_global_role" "viewer":
│   81:   actions = [
│   82:     "READ_APPLICATION",
│   83:     "READ_APPLICATION_VERSION",
│   84:     "READ_APPTRUST_POLICY",
│   85:     "READ_BUILD",
│   86:     "READ_INTEGRATIONS_PIPELINE",
│   87:     "READ_POOLS_PIPELINE",
│   88:     "READ_RELEASE_BUNDLE",
│   89:     "READ_REPOSITORY",
│   90:     "READ_SOURCES_PIPELINE",
│   91:   ]
│
│ Attribute actions[Value("READ_APPTRUST_POLICY")] value must be one of: ["READ_REPOSITORY" "ANNOTATE_REPOSITORY" "DEPLOY_CACHE_REPOSITORY" "DELETE_OVERWRITE_REPOSITORY""MANAGE_XRAY_MD_REPOSITORY" "READ_RELEASE_BUNDLE" "ANNOTATE_RELEASE_BUNDLE" "CREATE_RELEASE_BUNDLE" "DISTRIBUTE_RELEASE_BUNDLE" "DELETE_RELEASE_BUNDLE" "MANAGE_XRAY_MD_RELEASE_BUNDLE""READ_BUILD" "ANNOTATE_BUILD" "DEPLOY_BUILD" "DELETE_BUILD" "MANAGE_XRAY_MD_BUILD" "READ_SOURCES_PIPELINE" "TRIGGER_PIPELINE" "READ_INTEGRATIONS_PIPELINE" "READ_POOLS_PIPELINE""REPORTS_SECURITY" "WATCHES_SECURITY" "POLICIES_SECURITY" "RULES_SECURITY" "READ_POLICIES_SECURITY"], got: "READ_APPTRUST_POLICY"

When you outcomment the actions, which the providers claims they dont exists, terraform likes to remove them from the global role

import {
  id = "Viewer"
  to = platform_global_role.viewer
}
resource "platform_global_role" "viewer" {
  name         = "Viewer"
  description  = "Viewer Role"
  type         = "PREDEFINED"
  environments = ["DEV"]
  actions = [
    #"READ_APPLICATION", # <---
    #"READ_APPLICATION_VERSION", # <---
    #"READ_APPTRUST_POLICY", # <---
    "READ_BUILD",
    "READ_INTEGRATIONS_PIPELINE",
    "READ_POOLS_PIPELINE",
    "READ_RELEASE_BUNDLE",
    "READ_REPOSITORY",
    "READ_SOURCES_PIPELINE",
  ]
}
terraform plan -target=platform_global_role.viewer
platform_global_role.viewer: Preparing import... [id=Viewer]
platform_global_role.viewer: Refreshing state... [name=Viewer]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # platform_global_role.viewer will be updated in-place
  # (imported from "Viewer")
  ~ resource "platform_global_role" "viewer" {
      ~ actions      = [
          - "READ_APPLICATION",
          - "READ_APPLICATION_VERSION",
          - "READ_APPTRUST_POLICY",
            "READ_BUILD",
            "READ_INTEGRATIONS_PIPELINE",
            "READ_POOLS_PIPELINE",
            "READ_RELEASE_BUNDLE",
            "READ_REPOSITORY",
            "READ_SOURCES_PIPELINE",
        ]
        description  = "Viewer Role"
        environments = [
            "DEV",
        ]
        name         = "Viewer"
        type         = "PREDEFINED"
    }

Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.

Requirements for and issue

  • A description of the bug
  • A fully functioning terraform snippet that can be copy & pasted (no outside files or ENV vars unless that's part of the issue). If this is not supplied, this issue will likely be closed without any effort expended.
  • Your version of Artifactory (you can curl it at $host/artifactory/api/system/version)
  • Is your Artifactory Cloud or Self-Hosted: Saas
  • Your version of Terraform CLI: 1.15.7
  • Your version of Terraform provider: v2.2.10

Expected behavior

It should be possible to import global roles into terraform with the complete list of actions

Metadata

Metadata

Assignees

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