) and then pasting the code into my file, and when I try to run
again using the same code, Pulumi claims that there is a diff in the user data when the strings are the same?
Type Name Plan Info
~ └─ aws:ec2:Instance api update [diff: ~userData]
~ 1 to update
Do you want to perform this update? details
~ aws:ec2/instance:Instance: (update) 🔒
~ userData: "85de5fdec580fbc6617d9b2bfbddbae346a45ef4" => "85de5fdec580fbc6617d9b2bfbddbae346a45ef4"
1 month ago
That may be because it can't tell what's in the new user data because it's generated in an apply, or similar. If that's the case, then it'll report a diff during preview, but (assuming tha there really is no difference) the diff will be 0 during up, and the instance won't be recreated.
If you want to test this, you can removed all EC2 write privileges from the creds that Pulumi is using, then run
. The user data will be fully generated and you'll be able to tell if the user data really has change, and you're also protected from accidentally destroying the instance in the case where the user data has changed.