I recommend you to go with a custom environment variable. This way you will be able to easily reproduce the required behaviour outside of AWS (on your workstation or using other cloud provider).
Using curl
or checking for presence of /etc/cloud
would make your application behaviour dependent on third-party services/tools. Beside logic complexity (you'd have to handle possible curl
errors, like invalid response codes) that can lead to bugs you surely don't want to meet.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…