INSTANCE_ID not available from "runcmd"
Bug #1760460 reported by
Eric Dahl
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Wishlist
|
Unassigned |
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_
# runcmd executes these lines during the initial boot
runcmd:
- echo "INSTANCE_
```
To post a comment you must log in.
Thank you for filing a bug. Cloud-init does not provide the INSTANCE_ID env variable for runcmd as you say. You may be interested in using the instance-data.json in a jinja template. Please take a look:
https:/ /cloudinit. readthedocs. io/en/latest/ topics/ instancedata. html#using- instance- data