Giter Site home page Giter Site logo

Comments (5)

guineveresaenger avatar guineveresaenger commented on June 12, 2024

Hi @muhlba91 -

Pulumi resource providers are run as plugins on your local system, so any environment variables set on your system are usually available to your provider.

How did you try setting the nested environment variables, and what behavior did you expect? It may well be that this is not currently supported, but I want to make sure I fully understand :)

from pulumi-proxmoxve.

muhlba91 avatar muhlba91 commented on June 12, 2024

Hi @guineveresaenger,

thanks for getting back to me here. Let me give you a short overview of my assumptions and tries so far. :)

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:

export PROXMOX_VE_USERNAME="root@pam"
export PROXMOX_VE_PASSWORD="<password>"
export PROXMOX_VE_ENDPOINT="https://<ip_address>:8006/"
export PROXMOX_VE_INSECURE="true"

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:

Config: map[string]*tfbridge.SchemaInfo{
			"virtualEnvironment": {
				Type: makeType("virtualEnvironment", "VirtualEnvironment"),
				Elem: &tfbridge.SchemaInfo{
					Fields: map[string]*tfbridge.SchemaInfo{
						"endpoint": &tfbridge.SchemaInfo{
							Type: makeType("endpoint", "Endpoint"),
							Default: &tfbridge.DefaultInfo{
								EnvVars: []string{"PROXMOX_VE_ENDPOINT", "PM_VE_ENDPOINT"},
							},
						},
						"insecure": &tfbridge.SchemaInfo{
							Type: makeType("insecure", "Insecure"),
							Default: &tfbridge.DefaultInfo{
								EnvVars: []string{"PROXMOX_VE_INSECURE", "PM_VE_INSECURE"},
							},
						},
						"otp": &tfbridge.SchemaInfo{
							Type: makeType("otp", "OTP"),
							Default: &tfbridge.DefaultInfo{
								EnvVars: []string{"PROXMOX_VE_OTP", "PM_VE_OTP"},
							},
						},
						"password": &tfbridge.SchemaInfo{
							Type: makeType("password", "Password"),
							Default: &tfbridge.DefaultInfo{
								EnvVars: []string{"PROXMOX_VE_PASSWORD", "PM_VE_PASSWORD"},
							},
						},
						"username": &tfbridge.SchemaInfo{
							Type: makeType("username", "Username"),
							Default: &tfbridge.DefaultInfo{
								EnvVars: []string{"PROXMOX_VE_USERNAME", "PM_VE_USERNAME"},
							},
						},
					},
				},
			},
		},

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.

from pulumi-proxmoxve.

muhlba91 avatar muhlba91 commented on June 12, 2024

@guineveresaenger bumping this thread for support.

from pulumi-proxmoxve.

guineveresaenger avatar guineveresaenger commented on June 12, 2024

Hi again - apologies for the long delay.

To the best of my knowledge, our tooling does not have this capacity at this point, since every provider is ever so slightly different and may expect different settings/nesting.

We recommend the following:

  1. Continue with the workaround as listed in your README.
  2. File an issue in the pulumi-terraform bridge so that we can triage and track this issue properly at the source and see if it's feasible.
  3. As with anything, we of course welcome pull requests and you may find a fair bit of assistance on our community slack from other community members as well.

from pulumi-proxmoxve.

muhlba91 avatar muhlba91 commented on June 12, 2024

Moved to pulumi/pulumi-terraform-bridge#423.

from pulumi-proxmoxve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.