https://pulumi.com logo
#automation-api
Title
# automation-api
i

icy-controller-6092

06/14/2023, 12:47 AM
Hey there, that's pretty much it. I create workspaces with various cloud platforms in my main stack and export e.g. api keys, then need to configure the providers in the other standalone stacks
m

millions-furniture-75402

06/14/2023, 12:42 PM
So say you had a list Api Key Ids you created in your base infrastructure project and exported the outputs:
Copy code
export const apiAccessKeyIds = [...];
The the stack you create in the automation api can use a stack reference to get those outputs:
Copy code
const myBaseInfrastructureStack = new pulumi.StackReference("my-org/my-project/my-base-infrastructure-stack");
const apiAccessKeyIds = sharedInfrastructureStack.getOutput("apiAccessKeyIds");

apiAccessKeyIds.apply(apiAccessKeyIdsValue => {
  apiAccessKeyIdsValue.forEach(accessKey => {
    new aws.apigateway.UsagePlanKey(
      `${appName}-api-${accessKey}`,
      { keyId: apiAccessKeyIdsValue[accessKey] as string, keyType: "API_KEY", usagePlanId: apiAppUsagePlan.id },
      { additionalSecretOutputs: ["value"], parent: apiAppUsagePlan },
    );
  });
});
i

icy-controller-6092

06/14/2023, 5:52 PM
Hey catmeme, this works well if you're trying to wire the stack reference outputs into resource that created inside the inline program function... but it doesn't work if you're trying to configure providers that run before the program, e.g.
stack.setConfig('databricks:token', ...)
- in the end, Evan's solution to select a dummy stack is what did the magic trick: https://pulumi-community.slack.com/archives/C019YSXN04B/p1686690675302049?thread_ts=1686635500.103289&cid=C019YSXN04B