Hey guys, i'm trying to create a class to create e...
# python
Hey guys, i'm trying to create a class to create ec2 instance and then call it from my main but pulumi keeps thinking my userdata is changing even when its not, here's part of my class(tried to edit out as much as i can so some args might be missing):
Copy code
import pulumi
from pulumi_aws import ec2

class KSDBServerArgs:
    The arguments necessary to construct an `KSDBServer` resource.
    def __init__(self,
                 ks_id: str):
        Constructs an KSArgs.
        :param ks_id:
        :param user_data:

        self.ks_id = ks_id
        config = pulumi.Config()

        self.user_data = '''
        /usr/sbin/useradd -d /home/user -m -s /bin/bash user
        echo "user ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
        mkdir -p /home/user/.ssh
        chown -R user:user /home/user/.ssh
        chmod 700 /home/user/.ssh
        echo 'ssh-rsa {1}' >> /root/.ssh/authorized_keys

class KSDBServer(pulumi.ComponentResource):
    def __init__(self,
                 name: str,
                 args: KSDBServerArgs,
                 opts:pulumi.ResourceOptions = None):
        super().__init__('kenshoo:KS:KSDBServer', name, None, opts)
        self.name = name

        # Creating ec2 instance
        self.db_instance = ec2.Instance("aws-"+ args.ks_id + "-db",
Can you share the output from
preview --diff
as well?
Copy code
pulumi:pulumi:Stack: (same)
        +-aws:ec2/instance:Instance: (replace)
          ~ userData: "ff55eb8b81f6b18b46eee35607dcc044a8d9b9b8" => "\n        #!/bin/bash\n        hostname > /tmp/mortst\n        yum install git -y\n        git pull https://[secret]@github.com/kenshoo/ansible-common.git\n        /usr/sbin/useradd -d /home/deployer -m -s /bin/bash deployer\n        echo \"deployer ALL=(ALL:ALL) NOPASSWD: ALL\" >> /etc/sudoers\n        mkdir -p /home/deployer/.ssh\n        chown -R deployer:deployer /home/deployer/.ssh\n        chmod 700 /home/deployer/.ssh\n        echo 'ssh-rsa [secret]' >> /root/.ssh/authorized_keys\n\n        mkfs -t ext4 /dev/sdb\n        mkdir /kdata\n        echo '/dev/sdb /kdata ext4 defaults,noatime,data=writeback 0       0' >> /etc/fstab\n        mount /kdata\n        "
just to be clear, when i try to use the same code outside of the class in my main it works just fine, it also works in the class if i remove all variables (even though the variables should be the same all the time as they are from the config)