https://pulumi.com logo
#general
Title
# general
i

icy-controller-6092

12/21/2023, 5:07 AM
can a stackreference be used in the config file?
m

most-napkin-55076

12/21/2023, 8:16 AM
I'm don't think so. Why would you want a StackReference in your config file?
i

icy-controller-6092

12/21/2023, 8:20 AM
One micro stack has a EKS kubernetes cluster deployed, and the other micro stacks want the default k8s provider to use the config for the deployed cluster
m

most-napkin-55076

12/21/2023, 8:27 AM
Is it not sufficient to include whole or part of the stackreference string for the EKS cluster stack in the config, and then use that in the stack, similar to the example in the stack reference docs?
Copy code
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const stack = pulumi.getStack();
const org = config.require("org");

const stackRef = new pulumi.StackReference(`${org}/my-first-app/${stack}`)

export const shopUrl = stackRef.getOutput("url");
Source: https://www.pulumi.com/learn/building-with-pulumi/stack-references/
i

icy-controller-6092

12/21/2023, 10:32 AM
The string is used to configure the kubernetes provider which needs to be done before the program begins. I suppose I could use the automation api
s

salmon-account-74572

12/21/2023, 4:55 PM
You can create a Kubernetes provider in one stack that is based on a Kubeconfig accessed as a stack reference from another stack.
Here's an example in TypeScript: https://github.com/pulumi-zephyr/zephyr-app/blob/main/infra/index.ts (see lines 22 and 32)
i

icy-controller-6092

12/21/2023, 6:40 PM
Trying to avoid the approach where you have to keep passing the provider or parent resource option at each resource creation, it’s the default provider I want to configure ( not a second manual provider ).