Hello everyone, I’m new to Pulumi and have been s...
# general
o
Hello everyone, I’m new to Pulumi and have been struggling with an issue for several days. I’m using the Pulumi Automation API via REST to provision my infrastructure. Within my pipeline, I have multiple services and resources, and when a user requests the installation of a specific service, it should be added to the existing infrastructure. However, I’m encountering a problem where the installation of the requested service leads to the destruction of other services and resources in the infrastructure. Here’s an example to illustrate the problem: Let’s say I have an existing infrastructure called ABC. When I request to install service D, the expected outcome is to have service D added to the infrastructure (+D). However, what’s actually happening is that other resources from infrastructure ABC are being destroyed (+D -ABC) along with the installation of service D. To provide some context, here are the steps I take to install service D: 1. Select the stack. 2. Install service D. I’ve also attempted to address the issue by importing a stack reference and passing the exported output of infrastructure ABC as input to service D. However, even with this approach, the problem persists. I would greatly appreciate any assistance or guidance in resolving this issue. Thank you in advance for your help
b
Pulumi uses a desired state model to provision infrastructure. It sounds like during the REST call, you’re modifying the state of the stack which us removing all the infrastructure You can’t append to a service unless you append the code to the existing instantiation of service D, that isn’t how pulumi works
the way to design this is to provision an entirely new stack for service D and not modify the existing stack ABC at all
o
So you mean to say I’ve to use different stacks for installing different services and all these stacks should import resources from my main infra stack?
Or am I missing something?
b
yes, you can’t append resources to an existing stack in the way you want unless your rest API call somehow adds more resources to the code you use to define resources ABC
o
Can you point me to any links or docs that can help me to reuse resources from my infra stack but do all the changes in a separate stack. Thanks a lot for your response.
o
Thanks a ton 🙏
s
You may also find this article on using stack references helpful as well: https://www.pulumi.com/blog/iac-recommended-practices-using-stack-references/
o
Thank you 👍