instance metadata
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html#instance-metadata-returns
curl http://169.254.169.254/latest/meta-data/
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2SSM
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/
git clone
cd aws-glue-samples/utilities/Spark_UI/glue-3_0
docker build -t test .
https://github.com/aws-samples/aws-glue-samples/blob/master/utilities/Spark_UI/README.md
#!/bin/bash
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
echo "token $TOKEN"
CREDS=`curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2SSM`
#{
# "Code" : "Success",
# "LastUpdated" : "2023-05-23T03:41:54Z",
# "Type" : "AWS-HMAC",
# "AccessKeyId" : "ASIA2B4T4GJJ50000000",
# "SecretAccessKey" : "PMNqUrnn+3u00000000000000000000000000000",
# "Token" : "IQoJb3JpZ2luX2VjEKT///0000000000000000000000000000000000000000000000000000000000000000000005ypPUAiBlRcQfKxjzrUSrgwCkMpB6E3x1+4SpQkeSKoH0vcWiMSq7BQjN//////////8BEAMaDDY5MTI2Mjk5Mjk3OSIMfEct9iZxbNNNtaDXKo8Fkwfxh2FavSVij+mwVEpt4e9hHqngOffBCz/r9pnCMX5JZ1VFCininkSdxWTSZ43EjJl0qZqbC7FFU+tP7TFhyxkqisRs4fPhymaqNnHmAPkgboyke5PHsmQqz8Nl3tJBoP77AzLhA9paM67yNwj8yqBQ6xREoHhclTXLgd7IqSk98/egruIipcZdIVtdNqZPjx4BPc/wecAjrUiHvZWBpef3MSyoqqIft1YKgYiv2mkFiiK9126jZ6YWHOcwXogFy2aSz2BCav+g4hAU/NlZDXWxbYt2aBtMmo/jegnt9xLaC3BWUdVgdrj1F5WTpO0PXMT3mAB+TpvROUxg11s5t1GuaDjvZ19OJj2kCTSfH2Swy7iBFzjtaumySExCR/0BCJT5LLFcd2a7spH1WKEKzXwk2rur5xNwsX4riTg5rqH93mpvIpOrhZlhNboSrNTiNC/wJ5MNqeX6WiKk4cDpfJ0AjqiY9UtoRsKmzPoZ6GOtKrt5izZUjow+onNh3R4YuHKHedcrrb31TIVjcU5fBdfzyOUvrawy30kVWcaFrNbtNCsaXgBkge26FZdskZ3N7sPv3TNxyLjkTYnatVK21h1t0ZAI+FBtzux3KYlW3L2Ws4cge/idOOoRZ+EWbaxLblZ3YwkYug+f9DBkC40UiNwYCewRMbDS/Ziy4HI6ow6iN5nK3h+mb4EacS2N2YoTHIaw6rgpgwT2rCYU/L4caXksnD4iCzra2lHjgTouO3GxD5s3PVG+tp6VBau8HXmT/+iQLBWuAB/PUfIvhIYi6HW2TfDQ7SseGYhgaAnKr+wj8vo6ZRxjdA4ZhIxgXTL27b3QdJkBo/wul5zBznZnC0JHXdsdlUZEBzk8kUsM8jDp67CjBjqyAd2/WcermYnhViBRMgBVyiV3cP1eOgCJdU6M8J9PEsntkoNa25795ctDOR3CZYD9Q6mlla8TXKF3va5h8j3ozG7x0Q/BrPbqw6dFJ2XHtfQMKzijQORaAsv93b5dt40VCEI3v8payQ480XnBlkP/10RBdTA80icMFeu3Q1V3ecFBuWVQRXtieqGhYHf7qRx0Ha0LGDenFaMEV5BNhSTgkpawJMCg+PZKH6VdvEEnLZ7Lky8=",
# "Expiration" : "2023-05-23T09:55:41Z"
#}
echo "creds $CREDS"
AWS_ACCESS_KEY_ID=`echo -n $CREDS | grep -o 'AccessKeyId" : "[^"]\+' | cut -d: -f2 | sed 's/[ "]//g'`
AWS_SECRET_ACCESS_KEY=`echo -n $CREDS | grep -o 'SecretAccessKey" : "[^"]\+' | cut -d: -f2 | sed 's/[ "]//g'`
AWS_SESSION_TOKEN=`echo -n $CREDS | grep -o 'Token" : "[^"]\+' | cut -d: -f2 | sed 's/[ "]//g'`
echo $AWS_ACCESS_KEY_ID
echo $AWS_SECRET_ACCESS_KEY
echo $AWS_SESSION_TOKEN
LOG_DIR="s3a://aws-glue-assets-600000000079-sa-east-1/sparkHistoryLogs/"
docker rm -f test
#docker run -itd --name test -e SPARK_HISTORY_OPTS="$SPARK_HISTORY_OPTS -Dspark.history.fs.logDirectory=$LOG_DIR -Dspark.hadoop.fs.s3a.session.token=$AWS_SESSION_TOKEN -Dspark.hadoop.fs.s3a.access.key=$AWS_ACCESS_KEY_ID -Dspark.hadoop.fs.s3a.secret.key=$AWS_SECRET_ACCESS_KEY" -p 18080:18080 test:latest "/opt/spark/bin/spark-class org.apache.spark.deploy.history.HistoryServer"
docker run -itd --name test \
-e SPARK_HISTORY_OPTS="$SPARK_HISTORY_OPTS -Dspark.history.fs.logDirectory=$LOG_DIR -Dspark.hadoop.fs.s3a.access.key=$AWS_ACCESS_KEY_ID -Dspark.hadoop.fs.s3a.secret.key=$AWS_SECRET_ACCESS_KEY -Dspark.hadoop.fs.s3a.session.token=$AWS_SESSION_TOKEN -Dspark.hadoop.fs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider" -p 18080:18080 test "/opt/spark/bin/spark-class org.apache.spark.deploy.history.HistoryServer"