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

404 when attempting to create an artifactory_group #1129

Closed
5 tasks done
finn-block opened this issue Nov 14, 2024 · 5 comments
Closed
5 tasks done

404 when attempting to create an artifactory_group #1129

finn-block opened this issue Nov 14, 2024 · 5 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@finn-block
Copy link

Describe the bug
I am trying to create a group in our JFrog hosted Artifactory instance with Terraform. When I run terraform apply, it gives me an error.

Terraform file:

terraform {
  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "12.4.1"
    }
  }
}

provider "artifactory" {
  url = "http://blockxyz.jfrog.io"
  // supply JFROG_ACCESS_TOKEN as env var
}

resource "artifactory_group" "snapshots" {
  name = "test"
}

Terraform apply:

$ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # artifactory_group.snapshots will be created
  + resource "artifactory_group" "snapshots" {
      + admin_privileges = false
      + auto_join        = false
      + id               = (known after apply)
      + name             = "test"
      + policy_manager   = false
      + realm            = "internal"
      + reports_manager  = false
      + watch_manager    = false
        # (3 unchanged attributes hidden)
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

artifactory_group.snapshots: Creating...
╷
│ Error: Unable to Create Resource
│ 
│   with artifactory_group.snapshots,
│   on providers.tf line 15, in resource "artifactory_group" "snapshots":
│   15: resource "artifactory_group" "snapshots" {
│ 
│ An unexpected error occurred while creating the resource update request. Please report this issue to the provider developers.
│ 
│ Error: {
│   "errors" : [ {
│     "status" : 404,
│     "message" : "Not Found"
│   } ]
│ }
╵

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
  • Your version of terraform
  • Your version of terraform provider
$ curl https://blockxyz.jfrog.io/artifactory/api/system/version
{
  "version" : "7.100.2",
  "revision" : "80002900",
...
$ terraform version
Terraform v1.8.2
on darwin_arm64
+ provider registry.terraform.io/jfrog/artifactory v12.4.1

Expected behavior
I expect the group to be created and an error not to occur

Additional context

@alexhung
Copy link
Member

@finn-block Thanks for the report. Odd, this shouldn't been any error from basic resource creation. Let me try to reproduce.

@alexhung
Copy link
Member

alexhung commented Nov 14, 2024

@finn-block Using the following configuration, I am able to create a group with no error:

terraform {
  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "12.4.2"
    }
  }
}

provider "artifactory" {
  //  supply ARTIFACTORY_ACCESS_TOKEN / JFROG_ACCESS_TOKEN / ARTIFACTORY_API_KEY and ARTIFACTORY_URL / JFROG_URL as env vars
}

resource "artifactory_group" "test-group" {
  name             = "test-group"
}
alexh@alexh-mac terraform-provider-artifactory % terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # artifactory_group.test-group will be created
  + resource "artifactory_group" "test-group" {
      + admin_privileges = false
      + auto_join        = false
      + id               = (known after apply)
      + name             = "test-group"
      + policy_manager   = false
      + realm            = "internal"
      + reports_manager  = false
      + watch_manager    = false
        # (3 unchanged attributes hidden)
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

artifactory_group.test-group: Creating...
artifactory_group.test-group: Creation complete after 0s [id=test-group]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Terraform: 1.9.5
Artifactory: 7.100.2

Does the access token has admin permission?

@alexhung alexhung added the question Further information is requested label Nov 14, 2024
@finn-block
Copy link
Author

I believe so? How would I check? I used my admin account (which can create groups) and went to edit profile -> generate identity token.

@alexhung
Copy link
Member

@finn-block Ah, identity token. Let me test with that.

@finn-block
Copy link
Author

Hey @alexhung , thanks for looking at this! I think I just found the problem: when copy/pasting example code, I neglected to update the protocol scheme in the artifactory URL. url = "http://... gives a 404, url = "https://... seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants