← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1760460] Re: INSTANCE_ID not available from "runcmd"

 

instance-data is now the supported way to achieve this sort of behavior.
This can be done with:

## template: jinja
#cloud-config

# bootcmd executes during the first boot only
bootcmd:
  - echo "INSTANCE_ID={{v1.instance_id}}" >> /tmp/bootcmd

# runcmd executes these lines during the initial boot
runcmd:
  - echo "INSTANCE_ID={{v1.instance_id}}" >> /tmp/runcmd

** Changed in: cloud-init
       Status: Triaged => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1760460

Title:
  INSTANCE_ID not available from "runcmd"

Status in cloud-init:
  Fix Released

Bug description:
  The AWS-related environment variable `INSTANCE_ID` is not populated
  within the context of a "runcmd", like it is for a "bootcmd". In
  "bootcmd", the value is set to the AWS EC2 instance id, as obtained
  from the metadata endpoint.

  I reproduced this with a minimal cloud-init file:

  ```
  #cloud-config

  # bootcmd executes during the first boot only
  bootcmd:
    - echo "INSTANCE_ID=$INSTANCE_ID" >> /tmp/bootcmd

  # runcmd executes these lines during the initial boot
  runcmd:
    - echo "INSTANCE_ID=$INSTANCE_ID" >> /tmp/runcmd
  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1760460/+subscriptions



References