dirien / pulumi-vultr

Pulumi provider for Vultr
Apache License 2.0
16 stars 1 forks source link

Can't have the provider working #380

Closed MatheusAnciloto closed 2 weeks ago

MatheusAnciloto commented 2 weeks ago

Hi

I'm testing this package in a new stack and I just can't have the provider working. I've tested setting up with pulumi config set vultr:apiKey and even adding the provider, they both fail.

With only the config set I get these errors in my preview:

    error: pulumi:providers:vultr resource 'default_2_21_1_github_/api.github.com/dirien/pulumi-vultr' has a problem: `vultr:apiKey` is not a valid configuration key for the vultr provider. If the referenced key is not intended for the provider, please choose a different namespace from `vultr:`.
    error: pulumi:providers:vultr resource 'default_2_21_1_github_/api.github.com/dirien/pulumi-vultr' has a problem: `vultr:rateLimit` is not a valid configuration key for the vultr provider. If the referenced key is not intended for the provider, please choose a different namespace from `vultr:`.
    error: pulumi:providers:vultr resource 'default_2_21_1_github_/api.github.com/dirien/pulumi-vultr' has a problem: `vultr:retryLimit` is not a valid configuration key for the vultr provider. If the referenced key is not intended for the provider, please choose a different namespace from `vultr:`.

when I create the provider:

const vultrProvider = new vultr.Provider("vultr-provider", {
  apiKey: process.env.VULTR_API_KEY,
});

// Create a Kubernetes cluster on Vultr
const testCluster = new vultr.Kubernetes(
  "test-cluster",
  {
    region: "njc", // New Jersey
    version: "v1.31.0+1", // Use the latest available version
    label: "test-cluster",
    nodePools: {
      nodeQuantity: 1,
      plan: "vc2-4c-8gb", // This is equivalent to DO's s-4vcpu-8gb
      label: "test-nodepool",
    },
  },
  { provider: vultrProvider }
);
...

it fails like this:

    error: pulumi:providers:vultr resource 'vultr-provider' has a problem: could not validate provider configuration: Invalid or unknown key. Examine values at 'vultr-provider.rateLimit'.
    error: pulumi:providers:vultr resource 'vultr-provider' has a problem: could not validate provider configuration: Invalid or unknown key. Examine values at 'vultr-provider.retryLimit'.
    error: pulumi:providers:vultr resource 'vultr-provider' has a problem: could not validate provider configuration: Invalid or unknown key. Examine values at 'vultr-provider.apiKey'.

I'd like to understand what I'm missing here

I validated the API key env it's with the correct string and the vultr:apiKey does exist when I run pulumi config

MatheusAnciloto commented 2 weeks ago

I have it working now after understanding better this line here:

resourceInputs["apiKey"] = (args?.apiKey ? pulumi.secret(args.apiKey) : undefined) ?? utilities.getEnv("VULTR_API_KEY");

even though I've done pulumi config set vultr:apiKey and tried multiples with or without provider what really worked was removing this config and only exporting the env VULTR_API_KEY before pulumi up

toddgeist commented 2 weeks ago

I have the same problem. But I don't see how to fix it. I am missing something. Could you share some more of the code that worked for you?

Thank you

MatheusAnciloto commented 2 weeks ago

Hey @toddgeist

So in my case, I tried to follow the official docs from here first:

Use pulumi config set vultr:<option>.

The following configuration points are available for the vultr provider:

vultr:apiKey (environment: VULTR_API_KEY) - This is the Vultr API key. It can be found in the [Vultr API section](https://my.vultr.com/settings/#settingsapi).
vultr:rateLimit - Vultr limits API calls to 30 calls per second. This field lets you configure how the rate limit using milliseconds. The default value if this field is omitted is 500 milliseconds per call.
vultr:retryLimit - This field lets you configure how many retries should be attempted on a failed call. The default value if this field is omitted is 3 retries.

This didn't work, so I made sure that I didn't have any of this config set up in my pulumi stack. You can check by running a pulumi config.

So my alternative was running export VULTR_API_KEY=<key> in the same terminal that I run pulumi up, which works!

here's an example of a simple cluster I deployed to test the connection:

import * as pulumi from "@pulumi/pulumi";
import * as vultr from "@ediri/vultr";
import * as k8s from "@pulumi/kubernetes";
import * as docker from "@pulumi/docker";
import * as dotenv from "dotenv";

dotenv.config();

const testCluster = new vultr.Kubernetes("test-cluster", {
  region: "atl",
  version: "v1.31.0+1",
  label: "test-cluster",
  nodePools: {
    nodeQuantity: 1,
    plan: "vc2-1c-2gb",
    label: "test-nodepool",
  },
});
toddgeist commented 2 weeks ago

Thank you! That worked!

Todd