Hey guys, I set up some EC2 boxes with Pulumi and ...
# aws
Hey guys, I set up some EC2 boxes with Pulumi and I noticed that when I updated the SSH key on them via Pulumi, the EC2 volume was totally wiped and I had to reinstall everything. How can I avoid this happening in the future? For reference, here is my Pulumi code:
Copy code
interface CreateEc2InstanceArgs {
    name: string;
    stackName: string;
    instanceType: string;
    vpcId: pulumi.Output<string>;
    isPublic: boolean;
    enableHttp: boolean;
    sshPublicKey: string;
    rootBlockDevice: aws.types.input.ec2.InstanceRootBlockDevice;
    amiName?: string;
    userData?: string;
    useEip?: boolean;

const instance = new aws.ec2.Instance(instanceName, {
      // For now we are assuming that if the EC2 instance is public then we want a public IP.
      // This may not necessarily be true if we put it behind a load balancer.
      keyName: keyPair.keyName,
      associatePublicIpAddress: isPublic,
      rootBlockDevice: {
        tags: { Name: volumeName, Stack: stackName },
      vpcSecurityGroupIds: [securityGroup.id],
      ...(userData && { userData }),
      ami: ami.id,
      tags: { Name: instanceName, Stack: stackName },