Open muhlba91 opened 2 years ago
Hi @muhlba91
So my apologies for this - we should be picking the Env Vars up automatically but if that isn't working then in your provider/resources.go, you should be able to take advantage of the Config block to be able to do this:
Config: map[string]*tfbridge.SchemaInfo{
"region": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"AWS_REGION", "AWS_DEFAULT_REGION"},
},
},
"profile": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"AWS_PROFILE"},
},
},
},
That will allow you to be able to define the mapping between the TF schema for the provider and the Pulumi schema
Please let me know how that works out. I will continue trying to figure out why Env Vars are not working for nested config as this should be the case
Paul
Hi,
sorry for getting back so late. I posted my excerpt of the Config
property above already, which ended up throwing a could not read plugin [/Users/daniel/go/bin/pulumi-resource-proxmoxve] stdout: EOF
error. Did I miss anything in my definition?
Hello!
Issue details
Moving from https://github.com/muhlba91/pulumi-proxmoxve/issues/2 to here, as requested.
The Proxmox Terraform provider expects nested configuration or environment variables. However, setting environment variables does not work and we get a configuration error from the Terraform provider (https://github.com/bpg/terraform-provider-proxmox/blob/main/proxmoxtf/provider.go#L210).
Hence, we need to work-around like this:
It would be great if we can pass through environment variables configuration to the provider.
Steps to reproduce
First, the terraform provider defines it's configuration schema here: https://github.com/bpg/terraform-provider-proxmox/blob/main/proxmoxtf/provider.go#L71 - as you can see it generates a nested schema with - for example - those environment variables:
PROXMOX_VE_ENDPOINT
PROXMOX_VE_INSECURE
PROXMOX_VE_PASSWORD
PROXMOX_VE_USERNAME
Those I define in my environment variables like:
Based on the schema generated by the terraform bridge, the configuration is picked up correctly. See https://github.com/muhlba91/pulumi-proxmoxve/blob/main/provider/cmd/pulumi-resource-proxmoxve/schema.json#L1474 for the nesting, and https://github.com/muhlba91/pulumi-proxmoxve/blob/main/provider/cmd/pulumi-resource-proxmoxve/schema.json#L1395 for the nested schema.
If I now execute Pulumi using this provider, I receive
error: You must specify the virtual environment details in the provider configuration
(defined here: https://github.com/bpg/terraform-provider-proxmox/blob/main/proxmoxtf/provider.go#L210).Hence, my conclusion that the environment variables are not passed through to the provider configuration properly. To me it looks like the nested configuration for the provider is initialised (empty) and passed, leading to the terraform provider not calling the initialisation functions (default functions for each variable).
Then I thought I can simply define the configuration in the
resources.go
file like:Apart from the fact that I would expect it to work without such addition, I think I did something wrong here since I receive the following error when using the plugin now
error: could not load plugin for proxmoxve provider 'urn:pulumi:dev::pve-test::pulumi:providers:proxmoxve::default_0_0_1_alpha_1637516154_bcc93c62_dirty': could not read plugin [/Users/daniel/go/bin/pulumi-resource-proxmoxve] stdout: EOF
.Expected: The bridge takes the environment variables and maps them correctly. Actual: The bridge ignores the environment variables and/or doesn't map them to the nested configuration.