Hi all! is there any recommended way to deploy res...
# general
a
Hi all! is there any recommended way to deploy resources to only one stack in your project? for example, i only want to deploy an SNS topic and Cloudwatch alarms to my production stack, but not to my development or test stack. Thanks the help!
l
All deployments (
pulumi up
) are to only one stack. There is no other way to do it...
Ah wait, do you mean, you want some code to apply to one stack, and other code to apply to all stacks?
You can wrap the code in a conditional based on the stack name, but the general rule here is: don't do that.
Instead, use separate projects.
Take the SNS and Cloudwatch alarms out of the current project, so that everything that is left should be deployed to all environments.
Make a new project with the SNS and Cloudwatch alarm code, and create only a prod stack.
You can even use automation-api to orchestrate the two projects, if you like.
a
okay thanks for the feedback! That makes a lot of sense. I'm assuming dependencies across projects will still work in that case
l
Yes absolutely. There's a few ways to manage it, depending on the immutability of the resources, but the best way is to use stack references. https://www.pulumi.com/docs/intro/concepts/stack/#stackreferences
❤️ 2
p
I definitely do agree with the statement:
You can wrap the code in a conditional based on the stack name, but the general rule here is: don’t do that.
However, I’d add one additional approach that does not involve creating separate projects if you want (and can) keep things simple. You can still create a condition that’s based on some stack config values (and not its name).