- Le plus récent
- Le plus de votes
- La plupart des commentaires
Is it possible that the instance where this doesn't work is using IMDSv2? If so, see this other answer: https://repost.aws/questions/QUu_EQXMmAS8e3AA36LPeDyg/get-region-from-cli-in-cape-town#ANL7-jwi8ESge3axL-gTRHqA
The value returned from IMDS doesn't have a "newline" character at the end, which can cause the shell prompt to merge with or over-print the result in your terminal. You can try adding an echo
immediately after the curl
command to print a newline and make the value show up properly:
curl http://169.254.169.254/latest/meta-data/instance-id; echo
Thanks James for the quick reply. Unfortunately it's not a newline problem. As I was saying the same string on an ec2 server without IAM roles prints the instance id correctly.
Thanks for confirming. Note that you don't need any IAM permissions to fetch this information from IMDS though, so I'd discount that line of enquiry :)
Contenus pertinents
- demandé il y a 3 mois
- demandé il y a 10 jours
- demandé il y a 9 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
Thanks, that was exactly the cause! I refactored the bash code adding the token, all ok now, no errors. Unfortunately it doesn't seem to solve the cron competition problem, I will eventually open another specific post.
I was doing the wrong way of testing auto scaling with elastic beanstalk. The bash script with the token change for IMDSv2 manages to check crons correctly with the primary instance. Thanks again to everyone for the help.