can a stackreference be used in the config file?
# general
i
can a stackreference be used in the config file?
m
I'm don't think so. Why would you want a StackReference in your config file?
i
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
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
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
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
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 ).