I'm really struggling with handling dependencies. ...
# azure
m
I'm really struggling with handling dependencies. I have a component that I wrote which creates a vnet, list of subnest, public IPs, NSGs, route tables, their routes and rules, etc. However, I wanted to replace an NSG to update the name. Of course, I don't have logic to handle removing and re-adding a subnet so I can re-create the NSG. I'm surprised that Pulumi doesn't handle this for me since the dependencies are known. How does everyone else handle this situation?
Do I need to be writing in custom logic to handle this?
s
import ?
m
It's already in my state.
s
#comment it out in the code
#run pulumi, wait for it to remove it
#uncomment add changes ?
m
Pulumi generally will handle replacing resources that depend on a resource that is being replaced. Sometimes you have to explicitly tell Pulumi about that relationship if it's not explicit in the resource inputs (Resource Option: dependsOn)
m
@salmon-guitar-84472 That's the exact scenario I want to avoid. Ideally, it would create the new resource, associate it, then tear down the old one.
@miniature-twilight-47355 I'll try that out since I'm not explicitly calling out that relationship. However, relationship between snet and nsg feels like something that should be obvious from the state.
s
I believe this is where Pulumi hits the ceiling at the moment, we've found that any changes to vnet (which are not that uncommon IRL) are unfortunately very tricky and can easily end up with a lot of manual work and dealing with state discrepancies
it's even worse if you divide your infrastructure in sevral dependent stacks