You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make additional data from external auth provider available to resource coder_external_auth #12704
I wanted to set up the variable using the external-auth account as it makes more sense to be sync with the Gitlab account then the Coder account.
For now, we can only get the access_token from the resource "coder_external_auth", but it could open a lot of feature cases to have access to data like:
the username of the user
the full name of the user (the one I would need in my example)
I've tried to check in the codebase how complicated it could be to add it, but I couldn't manage to find the way it has been implemented
Feel free to ask if I'm not clear on what I'm suggesting
@kylecarbs that would be awesome but it seems that we can't use datasource data to configure a provider as it's loaded by terraform at first (unless I'm mistaken)
"You can use expressions in the values of these configuration arguments, but can only reference values that are known before the configuration is applied. This means you can safely reference input variables, but not attributes exported by resources (with an exception for resource arguments that are specified directly in the configuration)."
to export the access_token in a coder_env to be absolutely sure there is a token (and I've got one)
I've created a new template with the button "Create Template" > "From scratch", add your code, and try to build it, but it refuse to build (as I guess there is no external auth token when building the template)
To be able to build the template, I had to use some tricks so that it won't call gitlab unless he has a token
Activity
kylecarbs commentedon Mar 21, 2024
I think you could use the Gitlab current user data source to accomplish this.
We intentionally don't obtain extra data from the tokens because we could add so many fields that differ per provider.
kylecarbs commentedon Mar 21, 2024
@MaximeNoulin, it might look something like this:
MaximeNoulin commentedon Mar 21, 2024
@kylecarbs that would be awesome but it seems that we can't use datasource data to configure a provider as it's loaded by terraform at first (unless I'm mistaken)
kylecarbs commentedon Mar 21, 2024
@MaximeNoulin I believe you're mistaken. I've done this pattern before. You cannot use resources to configure a provider, but you can data sources.
MaximeNoulin commentedon Mar 21, 2024
Are you sure? I've tried it for the past few hours and I couldn't make it work
And then I found this doc on terraform documentation: https://developer.hashicorp.com/terraform/language/providers/configuration
"You can use expressions in the values of these configuration arguments, but can only reference values that are known before the configuration is applied. This means you can safely reference input variables, but not attributes exported by resources (with an exception for resource arguments that are specified directly in the configuration)."
kylecarbs commentedon Mar 21, 2024
@MaximeNoulin just tried it.
Exact code:
MaximeNoulin commentedon Mar 21, 2024
Well I'm getting crazy here ahah
I've tried:
To be able to build the template, I had to use some tricks so that it won't call gitlab unless he has a token
I got the error
And the error seems to be the same if I force "-" as a token
kylecarbs commentedon Mar 21, 2024
Super weird. You could always just use the HTTP data provider and make the call yourself... but that's kinda weird.
MaximeNoulin commentedon Apr 2, 2024
Thanks a lot @kylecarbs i'll do that then