abundant-rain-94621
01/13/2023, 6:15 AMminiature-musician-31262
01/13/2023, 6:54 AMthe problem is that the stacks reference the same resources so my delete on test stack will delete all my main which is not desirable.I’m wondering how this is so (specifically multiple stacks operating on the same resources); it sounds unusual. Are you able to share any code from your program?
abundant-rain-94621
01/13/2023, 9:14 AMminiature-musician-31262
01/13/2023, 5:12 PMmain
stack would record that the bucket belonged to main
. If you then switched to the test
stack and ran pulumi up
, Pulumi would recognize that the test
stack didn’t yet have a bucket, so it’d create a new one for that stack.
By default, Pulumi “auto-names” all resources uniquely by stack, meaning the actual bucket deployed for main
would be different (e.g., bucket-abc
) from one deployed for test
(e.g., bucket-123
). You could, however, “hard-code” a bucket name into your program such that deployments of main
and test
would try to use the same bucket name — but even if you did that (which is generally not recommended, but even so), the initial deployment of test
, following a successful deployment of main
, would fail because the bucket deployed by main
would already exist at the cloud provider (so the second creation attempt would be rejected) — and running destroy
on a not-yet-deployed stack would have no effect (even if the bucket name were hard-coded and already deployed in main
) because Pulumi would not have recorded that bucket as belonging to test
, as it wouldn’t have been deployed in that stack.
So yes, in actual practice, it’s quite difficult to do this. You’d likely have to perform some sort of manual surgery on your state file somehow, and manually overwrite the state of the test
stack, in order to do it. Definitely wouldn’t be an easy thing to do by accident.abundant-rain-94621
01/15/2023, 2:58 AM