amazon-linux-2023 icon indicating copy to clipboard operation
amazon-linux-2023 copied to clipboard

[Bug] - Cloud-Config user-data to power off not running

Open petercooperjr opened this issue 1 year ago • 2 comments

Describe the bug A directive given in cloud-config user-data to poweroff after cloud-config data runs doesn't seem to do anything in Amazon Linux 2023, though the same user-data works on Amazon Linux 2.

To Reproduce Testing done in the us-east-1 region.

Create a file power-off.cloud-config with these contents:

#cloud-config
power_state:
  delay: now
  mode: poweroff

Start an instance using that file as user-data:

aws ec2 run-instances --image-id resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64 --instance-type t4g.nano --instance-initiated-shutdown-behavior terminate --user-data file://power-off.cloud-config

The instance launches, but does not turn off and terminate on its own as directed.

Expected behavior If doing the same thing with Amazon Linux 2, the instance does shut itself down and terminate after running the cloud-config data:

aws ec2 run-instances --image-id resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-arm64-ebs --instance-type t4g.nano --instance-initiated-shutdown-behavior terminate --user-data file://power-off.cloud-config

Additional context Obviously my actual case is a cloud-config with more commands to run on bootup and then having the instance terminate itself after running them; this is just a minimal example to reproduce the problem.

  • Cloud-init documentation of power_state directive: https://cloudinit.readthedocs.io/en/latest/reference/modules.html#power-state-change

petercooperjr avatar Mar 25 '23 20:03 petercooperjr