Somehow i accidentally removed route table associa...
# aws
Somehow i accidentally removed route table associations from my infrastructure. Was able to re-associate the subnets with the route tables in the AWS console, but now
pulumi refresh
wants to delete them from my state, while
pulumi preview
shows that state matches the code (including import IDs), and isn't trying to create any new ones. Any ideas what's going on here?
Sounds expected. AWS differs from state, so refresh wants to fix that. Code doesn't differ from state, so preview reports no differences.
Your options are 1) to fix AWS first; that will stop refresh from noticing the difference; 2) to not fix AWS at all, run refresh then up, so that Pulumi fixes AWS for you.
The refresh+up option is great when it works, but I find that it often changes values that aren't in your code (that is, puts AWS defaults into state), so now code and state are different. When you run up, changes will happen that effectively do nothing (essentially removing defaults from state). Usually this is fine, but sometimes this causes unwanted updates or delete-replaces. Which can be very bad if it's in RDS, Aurora, Directory Services, etc. So be attentive to the preview before running up!
thank you- what i'm baffled by is that i made the route table associations in AWS console but pulumi isn't recognizing their existence with
pulumi refresh
That's because you haven't imported them yet.
maps something-in-AWS-with-ID-X to something-in-state-with-ID-X.
But you've got something-in-state-with-ID-X and something-in-AWS-with-ID-Y
You need to use the
opt to tell Pulumi that AWS ID Y is the same as Pulumi ID X.
(Whoops, typo back a few lines, fixed it, would have mislead you if you read it before)
this may be the bit i was missing- i'll check into that. thanks!
👍 1
ok since i had the resource IDs defined as options in the code, this is how i fixed it: 1.
pulumi refresh
(and allow the resources to be removed from the state) 2.
pulumi up
which caused the imports to succeed They do indeed have new IDs now.
Yes, that's always the best way, so long as you don't get an unintended update, as described above. Glad it worked!
thanks for your help