EC2 metadata not available in runCommand

So I just ran across this myself. It looks like on my EC2 Nixos host, it’s running dhcpcd to get its network configuration – but this creates interfaces and routes for 169.254.0.0/16, intercepting any requests to Amazon’s instance-metadata service.

This is also breaking the “ec2metadata” CLI tool in cloud-utils.

I think the best thing to do may be to configure networking manually – which probably means using an elastic IP address (which I want to do anyway, after I have this running correctly).

Does anyone have good guidance on running Nixos on EC2 that has solved this problem – being able to reach the instance metadata service at http://169.254.169.254 ?