Hey everyone, First of all, thank you for taking ...
# general
c
Hey everyone, First of all, thank you for taking the time to read this. We are currently using the
@pulumi/pulumi/automation
package in one of our projects (using node.js). I run the following only once, when starting the server:
Copy code
const stack: Stack = await LocalWorkspace.selectStack(
 {
  stackName: `sample-stack`,
  workDir: 'sample'
 },
 {
  envVars: {
   PULUMI_ACCESS_TOKEN: process.env.PULUMI_ACCESS_TOKEN ?? '',
   AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ?? '',
   AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY ?? ''
  }
 }
)
After this, I use the selected stack in my services and call
await stack.setConfig
to set some configuration values. This all works and the configuration is showing up perfectly fine in the pulumi ui for my specific stack. Also
pulumi up
runs without issues and uses the configuration as intended. However, when I redeploy my server from scratch and select the exact same stack with the code snippet above and then log
await stack.getAllConfig()
the configuration returns an empty object. I would expect the configuration that is visible in the pulumi ui, to be retrievable through this
await stack.getAllConfig()
even after redeploying from scratch. It does work when I do not redeploy or restart though, but this won’t last forever 😉 Am I missing something or doing something wrong here? Or is it not a feature of this package? Looking forward to your answers! 🙂
b
just to confirm, you’re running
stack.getAllConfig()
after you’ve run a destroy?
stack.getAllConfig
will only return a value after a successgul
stack.up
operation
c
Thanks for your reply @billowy-army-68599 I take the following steps: 1. Start server and run the stack init/select, call some endpoints which sets configuration. Then I run a pulumi up which sets configurations and deploys resources. 2. Destroy server 3. Start server again from scratch and run a stack init/select. Then, without doing anything or running a pulumi up, I run
stack.getAllConfig()
which returns an empty object. If I would run a pulumi up in step 3, after running the stack selection but before anything else, it cleans configurations and deletes all resources
b
stack init on its own won’t set any config.
you need to run
getAllConfig
after you run
setConfig
c
so selecting the existing stack wont give the possibility to get the already existing config from Pulumi (state)? Instead we need to store this configuration yaml somewhere and get it from this location to recover the previous configuration?
b
sorry, when you say “Destroy server” do you mean run a
pulumi destroy
?
or destroy the server you’re running automation API on?
c
yes destroy the server I am running the automation api on
b
ohhh, in that case, your local copy of the config hasn’t been retrieved, run a
refresh
first after you select the stack
c
ahh great, that worked. Tried a refresh before but must have made a mistake when using the
pulumi.refresh()
(since that one also cleaned my configuration) instead of the
pulumi.refreshConfig()
😄 Thanks a lot 🙂