Closed ulucinar closed 2 years ago
Then as discussed previously, we could read those env. variables injected into container's runtime in the main function, and have their values flow into tfcli runtime
What do you think about having the ProviderConfigBuilder
to return a function that's initialized with global info in main.go
and have that func
called by Connect
with credentials, which would produce a single JSON blob with source, version and credentials info? It'd require changes in lower parts of the stack but it could simplify the structure, i.e. all provider configurations are prepared by ProviderConfigBuilder.
With global info do you mean a global variable?
@ulucinar no, I mean the configuration that spans all instances that this provider will reconcile, i.e. source
and version
in HCL. return a function that's initialized
could be confusing. I was meaning something like this:
// source and version taken from env var in main.go
func ToBeCalledFromMain(source, version string) ProviderConfigBuilderFn {
return func(...) ([]byte, error) {
// use source and version strings here.
// Final blob would include credentials, source, version, i.e. all provider configuration TF needs.
}
}
The result of that function, i.e. ProviderConfigBuilderFn
, would be given to controller.Setup
as you described.
We had a chat with @muvaf for the tech-preview releases of provider-tf-azure
& provider-tf-aws
that are planned for 13th of September, 2021. We have decided to reintroduce configuration from env. variables for tfcli to make things smoother for now. Once this issue is resolved, we can remove env configuration from tfcli again. cc. @turkenh
What problem are you facing?
tfcli runtime needs the Terraform provider source and version at runtime for correctly generating the corresponding provider block in per-resource Terraform configuration. We need to capture this information during container image build time and make it available to the tfcli runtime.
How could Terrajet help solve your problem?
The source of truth for the provider source and version constraint could be two env. variables, as both of pieces of information are also needed when preparing the local Terraform image mirror. Then as discussed previously, we could read those env. variables injected into container's runtime in the
main
function, and have their values flow into tfcli runtime via the following path:main -> (generated) controller.Setup -> <(generated) resource>.Setup -> terraform.SetupController
and stored interraform.connector
to be used by tfcli.