-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conditional Artifactory usage requires access token and URL while they are not used #1175
Comments
@tomvmeer The checks/usages for the Artifactory URL and token are part of the provider initialization process. At that time, the provider does not know if there are any resources being used so it is not possible to skip the check/usage. |
@alexhung thanks for your response! What I then don't understand is why this still works: terraform {
required_providers {
artifactory = {
source = "jfrog/artifactory"
version = "12.8.1"
}
}
}
provider "artifactory" {
url = null
access_token = null
}
... some none Artifactory related code
The provider seems to understand no resources will be created using it and it does not initialize? |
@tomvmeer This is most likely Terraform itself sees that no |
I understand, I see other providers solve this issue by only trying to create the connection to the external system during the apply stage of a specific resource (see for example This one). Given that resources with count=0 are not included in the apply, the issue presented here does not occur. Is this something the Artifactory Terraform provider could implement too? |
@tomvmeer It is a conscious design decision and trade off. The other providers don't check for empty URL/token and makes API requests regardless whether they are set. This will generate authentication error during apply time. In JFrog providers, we check the URL/token during provider initialization so that the unset/empty values is caught as soon as possible. This benefits most of our users as empty URL/token is very likely a mistake and unintended. You may be interested in using OpenTofu instead. Looks like they are adding optional/conditional provider: https://github.com/opentofu/opentofu/releases/tag/v1.9.0 HashiCorp added similar concept but only to their HCP offering as Stacks. |
Thanks for the discussion @alexhung I will close this issue now! |
Describe the bug
artifactory_file
data source with count of 0 causes Terraform plan to try to authenticate with Artifactory.Requirements for and issue
Expected behavior
The provider should not try to contact the Artifactory to Authenticate when the Artifactory is not being used at all.
The text was updated successfully, but these errors were encountered: