Can I "piggyback" off of another providers config/authentication in my custom provider?

I want to create a custom provider that will be accessing gcp resources

Is there a way to just use and explicitly depend on an existing google provider config for getting access to gcp in my custom provider? It would be nice if my custom provider requires no config (except for declaring it in the tf config of course) and it just uses the google provider config.

As opposed to setting all that up myself or copy/pasting the provider config code from the google provider into my custom one.

There is no direct way for one provider to access another provider’s configuration.

However, you could approximate it at least in part by making your provider expect the same set of environment variables for parts of the provider configuration that make sense to configure via environment variables, and then you can set those environment variables only once in your session and have both providers find them.

I could find this myself but where is the area of code I could copy/paste from the google provider for this?

Did you look into the GOOGLE_ environment variables in provider.go?

1 Like