https://pulumi.com logo
Title
m

millions-ability-32682

07/14/2021, 6:52 AM
I would like to make a project with two stacks: one for a VM, and one for the stuff that runs on the said VM. I have come up with the following project structure after reading the Pulumi documentation:
$ tree -I node_modules $(pwd)
/workspaces/tmnf-do
├── package.json
├── package-lock.json
├── Pulumi.tmnf-server.yaml
├── Pulumi.vm.yaml
├── Pulumi.yaml
├── stacks
│   ├── tmnf-server
│   │   └── index.ts
│   └── vm
│       ├── index.ts
│       └── userdata.sh
└── tsconfig.json
Then I changed the
main
setting of the two stacks to point to the stack directory:
$ tail -n +1 Pulumi.*.yaml
==> Pulumi.tmnf-server.yaml <==
main: stacks/tmnf-server

==> Pulumi.vm.yaml <==
main: stacks/vm

config:
  digitalocean:token:
    secure: [redacted]
But when I run
pulumi up --stack vm
I get the following warning:
Diagnostics:
  pulumi:pulumi:Stack (tmnf-do-vm):
    We failed to locate the entry point for your program: /workspaces/tmnf-do
    Here's what we think went wrong:
      * Your program's 'main' file (/workspaces/tmnf-do/index.js) does not exist.
Which leads me to think that pulumi is still looking for the program in the project directory, disregarding the
main
setting from stack config files. My question is: should a setup like this be possible, and should it even be possible to override
main
per stack like I am trying to do?
w

witty-candle-66007

07/14/2021, 1:09 PM
Pulumi looks for the program in the current directory. But you can tell it to find the config file elsewhere with the
--config-file
parameter. So, you can run
pulumi up --stack vm --config-file ./../Pulumi.vm.yaml
FROM the stacks/vm folder.
m

millions-ability-32682

07/14/2021, 4:09 PM
Interesting. But if I have to do it this way, I might as well just have two distinct projects.
w

witty-candle-66007

07/14/2021, 4:34 PM
That is generally the model used. Can you explain the use-case that is driving you towards wanting a single project for what I’m guessing are two fundamentally (substantially?) different stacks?
m

millions-ability-32682

07/14/2021, 7:39 PM
What is driving me is not a use case, but a misunderstanding of terminology. I though that a stack was a collection of resources (like in CloudFormation), and that a project was a collection of stacks that together comprise an application. But it appears that a stack is more like an environment (as in staging, test, dev, prod etc.), and a project is the combination of all of the environments. Thanks a lot for clearing this up for me, @witty-candle-66007.
w

witty-candle-66007

07/14/2021, 7:49 PM
Yes, the terminology can be a bit confusing at times given the same terms are used in other non-pulumi contexts in different ways. If you haven’t already found these docs pages, they’ll probably help further: • https://www.pulumi.com/docs/intro/concepts/https://www.pulumi.com/docs/intro/concepts/project/https://www.pulumi.com/docs/intro/concepts/stack/
❤️ 1
m

millions-ability-32682

07/14/2021, 9:10 PM
Yes-yes, thank you. I understand now that stacks are instances of a project; stacks are not components of a project.