Hi, I am a relatively new user of Pulumi and IaC i...
# aws
Hi, I am a relatively new user of Pulumi and IaC in general, but iā€™m loving the experience. I have a question about pulumi destroy and the order of steps when deleting resources. I create an internet gateway and map 2 public subnets to it via routetableassociation but when i execute pulumi destroy i get an error about not being able to detach the internet gateway from the VPC because there are still public subnet addresses mapped to it. Here is the error message:
I think the problem with the security groups is that the rules (which refer to the other security groups) would need to be removed before the groups. For the routetableassociations I think if you make it so the DependOn the internet gateway they should be destroyed before it.
@polite-napkin-90098 thank you. So i declare my public subnets first and then when i create my internet gateway i specify in the resourceoptions that it depends on the subnets resources
Copy code
igw_name = f'{name}-igw'
        self.igw = ec2.InternetGateway(igw_name,
                                           'Name': igw_name
i guess that will enforce the order of the destroy steps. It will first remove the subnets then it will be able to detach the gateway from the VPC
Yes, that's my understanding. But I hasten to add I'm fairly new to pulumi myself
šŸ‘ 1
yes, that is correct. From the docs:
option ensures that resource creation, update, and deletion operations are done in the correct order.
šŸŽ‰ 1