https://pulumi.com logo
Title
a

adamant-leather-41068

12/07/2022, 4:52 AM
I have some EC2 instances managed by Pulumi. Various config files are written using
cloudinit
. If I change this data, Pulumi correctly identified the resources affected and shutsdown the correct EC2 instances. However, it doesn't write the new config data, so when it starts up the machines the old versions are still there. If I manually terminate the EC2 instances, then run
pulumi refresh
and
pulumi up
it all works. What am I doing wrong?
m

millions-furniture-75402

12/07/2022, 2:17 PM
How is cloudinit setup? userData?
a

adamant-leather-41068

12/08/2022, 12:20 AM
Yes. As a snippet of the part that doesn't seem to work:
write_files: [
{
        permissions: '0644',
        path: '/root/conf/storage-node.env',
        // this writes the .env file from what has been loaded
        content: Object.entries({ ...nodeConfig })
          .map(([key, value]) =>
            `${key.trim().replace(/[A-Z]/g, s => `_${s}`).toUpperCase()}=${value}`)
          .join('\n')
      }
{
        permissions: '0664',
        path: '/root/conf/haproxyconf/haproxy.cfg',
        content: haProxyCFG,
      }
]
Specifically the
storage-node.env
isn't getting updated.
m

millions-furniture-75402

12/08/2022, 2:03 PM
Could this have anything to do with cloud-init boot stages and this not being a first boot? https://cloudinit.readthedocs.io/en/latest/topics/boot.html
You may be able to debug at runtime using the following advice https://stackoverflow.com/a/50911376
a

adamant-leather-41068

12/10/2022, 6:07 AM
@millions-furniture-75402 thanks. Looks like it may well be the cloud-init boot stages thing. How do most people handle this problem with Pulimi?
m

millions-furniture-75402

12/11/2022, 8:17 PM
It's not a Pulumi problem. It's a configuration management issue. You can: 1. Trick your EC2 into redeploying for another reason 2. Figure out how to get your userdata change to trigger cloud-init again 3. Use another configuration management tool, such as ansible or puppet