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

api_key cannot be defined without access_token #966

Closed
kelvin-glass-db opened this issue May 16, 2024 · 1 comment · Fixed by #967
Closed

api_key cannot be defined without access_token #966

kelvin-glass-db opened this issue May 16, 2024 · 1 comment · Fixed by #967
Assignees
Labels
bug Something isn't working

Comments

@kelvin-glass-db
Copy link

Describe the bug
I cannot specify api_key since it fails and requests to specify access_token (which then takes precedence)
(I am aware that the key is deprecated and I want to move to the token asap 😃 )

I reduced my problem to the following dummy code

terraform {
  required_version = ">= 1"
  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "10.7.6"
    }
  }
}

provider "artifactory" {
  url           = "https://jfrog.com"
  check_license = false
  api_key       = "not-a-real-key"
}


data "artifactory_file" "code" {
  repository  = "no-real-repo"
  path        = "no-real-path"
  output_path = "${path.module}/code.zip"
}

failing with

│ Error: Missing JFrog Access Token
│
│   with provider["registry.terraform.io/jfrog/artifactory"],
│   on test.tf line 11, in provider "artifactory":
│   11: provider "artifactory" {
│
│ While configuring the provider, the Access Token was not found in the JFROG_ACCESS_TOKEN/ARTIFACTORY_ACCESS_TOKEN environment variable or provider
│ configuration block access_token attribute.
╵

I assume the problem is that only the token is validated without checking if the key was specified:

if accessToken == "" {
resp.Diagnostics.AddError(
"Missing JFrog Access Token",
"While configuring the provider, the Access Token was not found in "+
"the JFROG_ACCESS_TOKEN/ARTIFACTORY_ACCESS_TOKEN environment variable or provider "+
"configuration block access_token attribute.",
)
return
}

With:

  • Terraform v1.7.5 on darwin_arm64
  • provider registry.terraform.io/jfrog/artifactory v10.7.6
  • Artifactory 7.41.12

Expected behavior
The Terraform run is successfully authenticating using the api_key and does not ask for the access_token.

Additional context
Add any other context about the problem here.

@kelvin-glass-db kelvin-glass-db added the bug Something isn't working label May 16, 2024
@alexhung
Copy link
Member

@kelvin-glass-db Thanks for the report! I've added this issue to our plan.

alexhung added a commit that referenced this issue May 16, 2024
…validation' into GH-966-fix-api-key-access-token-validation
alexhung added a commit that referenced this issue May 16, 2024
alexhung added a commit that referenced this issue May 17, 2024
alexhung added a commit that referenced this issue May 17, 2024
…lidation

Fix unable to use api_key without setting access_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants