From 5f671255daa83cac46cadd2c24c29503ff9e34eb Mon Sep 17 00:00:00 2001 From: Thomas Maureira Date: Thu, 6 Jun 2024 10:25:50 -0400 Subject: [PATCH] Update cron-leaderonly-linux.config fix: use /api/token to obtain metadata INSTANCE_ID and REGION --- .../instance-configuration/cron-leaderonly-linux.config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configuration-files/aws-provided/instance-configuration/cron-leaderonly-linux.config b/configuration-files/aws-provided/instance-configuration/cron-leaderonly-linux.config index c9514c4..45813c9 100644 --- a/configuration-files/aws-provided/instance-configuration/cron-leaderonly-linux.config +++ b/configuration-files/aws-provided/instance-configuration/cron-leaderonly-linux.config @@ -75,8 +75,9 @@ files: group: root content: | #!/bin/bash - INSTANCE_ID=`curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null` - REGION=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document 2>/dev/null | jq -r .region` + AWS_TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") + INSTANCE_ID=`curl -H "X-aws-ec2-metadata-token: $AWS_TOKEN" http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null` + REGION=`curl -s -H "X-aws-ec2-metadata-token: $AWS_TOKEN" http://169.254.169.254/latest/dynamic/instance-identity/document 2>/dev/null | jq -r .region` # Find the Auto Scaling Group name from the Elastic Beanstalk environment ASG=`aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" \