https://pulumi.com logo
#aws
Title
# aws
r

rhythmic-branch-12845

07/29/2022, 9:34 AM
hi, I am importing an EC2 instance (using
pulumi import
) and then pasting the code into my file, and when I try to run
pulumi up
again using the same code, Pulumi claims that there is a diff in the user data when the strings are the same?
Copy code
Type                 Name        Plan       Info
     pulumi:pulumi:Stack  test-dev
 ~   └─ aws:ec2:Instance  api         update     [diff: ~userData]

Resources:
    ~ 1 to update
    1 unchanged

Do you want to perform this update? details
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:dev::test::pulumi:pulumi:Stack::test-dev]
    ~ aws:ec2/instance:Instance: (update) 🔒
        [id=i-0a1fd51cf5f02a8b4]
        [urn=urn:pulumi:dev::test::aws:ec2/instance:Instance::api]
        [provider=urn:pulumi:dev::test::pulumi:providers:aws::default_5_10_0::bdc3a497-cbed-47f9-98ef-99acbed1740f]
      ~ userData: "85de5fdec580fbc6617d9b2bfbddbae346a45ef4" => "85de5fdec580fbc6617d9b2bfbddbae346a45ef4"
l

little-cartoon-10569

07/31/2022, 9:53 PM
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
pulumi up
. 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.