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

Enable null api_token provider configuration #1798

Open
1 task
Conflit-de-Bus opened this issue Jul 31, 2024 · 2 comments
Open
1 task

Enable null api_token provider configuration #1798

Conflit-de-Bus opened this issue Jul 31, 2024 · 2 comments
Labels
customer request Reported by a customer, but opened by Aiven staff enhancement New feature or request

Comments

@Conflit-de-Bus
Copy link

What is currently missing?

The Aiven provider can not be initialized with null values for the api_token value.

This can cause problems, especially since the addition of application users to Aiven in april.

In our Terraform stacks, we can get application user credentials from another in-house provider. However, because these are created with a resource, they are evaluated after the initialization phase of the provider. Not being able to initialize the provider with a null api_token means a Terraform stack using this principle needs to have its configuration changed after the credentials are generated, to add the Aiven resources after the fact.

If such an operation is attempted now, the following message is returned by the Aiven provider during the terraform plan:

│ Error: token is required for Aiven client
│ 
│   with provider["registry.terraform.io/aiven/aiven"],

Which I guess comes from this part:

return nil, fmt.Errorf("token is required for Aiven client")

How could this be improved?

This could be improved if the provider accepted null (or placeholder) values in its initialization phase.

Is this a feature you would work on yourself?

  • I plan to open a pull request for this feature.
@byashimov byashimov added enhancement New feature or request customer request Reported by a customer, but opened by Aiven staff labels Nov 8, 2024
@byashimov
Copy link
Contributor

Hey!
Could you share a bit more about how you’re using (or planning to use) the Aiven provider? And how would you like to handle passing the token to the provider within your workflow?

Thanks!

@Conflit-de-Bus
Copy link
Author

Hello @byashimov

Thank you for your answer, and sorry for the delay.

What I'd like to be able to do, is to initialize the Aiven provider, without needing credentials passed to it. In other words, I'd like it to fail when trying to perform the api calls necessary for the resource management, not at the beginning of the plan. I don't need it do do anything, just not throw an error when trying for a plan.

This is important to us, because we have an internal custom provider, that creates our Aiven projects, as well as gives us the credentials to connect to them.

For example, I'd like the following code:

resource "our_internal_aiven_project_creator" "aiven_project" {
  <some configuration>
}

resource "aiven_pg" "pg" {
  <some configuration>
}

provider "aiven" {
  api_token = our_internal_aiven_project_creator.aiven_project.aiven_token
}

to be able to plan without problems. Currently, this would throw "Error: token is required for Aiven client" because the aiven_token value is not defined at the beginning of the plan

In general, I'd just like to be able to do

provider "aiven" {
  api_token = null
}

Even if the apply fails when trying to create the PG service, at least we can apply our Terraform code selectively, and don't need to edit the code itself: we can create the infrastructure in 2 steps, one for the project/credentials, and one for the pg service.

I hope my explanation is understandable, if not, I can try to give additional details. This is something that works on the google tf provider, and having this would greatly help us.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer request Reported by a customer, but opened by Aiven staff enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants