This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
imdsv2 and tags - fixes #61
Open
BenCodeOcean
wants to merge
4
commits into
awslabs:master
Choose a base branch
from
codeocean:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nathanthorpe
reviewed
Apr 4, 2023
@@ -32,19 +32,19 @@ function get_metadata() { | |||
local key=$1 | |||
local metadata_ip='169.254.169.254' | |||
|
|||
if [ ! -z "$IMDSV2" ]; then | |||
if [ ! -z "$(get_config_value .imdsv2)" ]; then | |||
local token=$(curl -s -X PUT "http://$metadata_ip/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60") | |||
local token_wrapper='-H "X-aws-ec2-metadata-token: $token"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing this locally and it doesn't expand out properly when using single quotes.
> token_wrapper='-H "X-aws-ec2-metadata-token: $token"'
> echo $token_wrapper
-H "X-aws-ec2-metadata-token: $token"
Changing it to this works
> token_wrapper='-H "X-aws-ec2-metadata-token: '"$token"'"'
> echo $token_wrapper
-H "X-aws-ec2-metadata-token: <snip>"
The AMI I'm using is ami-0c6ee50d15e7364d4
This shows up in cloudwatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I see that eval
fixes it...
@wleepang would you be able to review this? |
Ah!!! I didnt see this PR till just now. I ran into the same issue of $token not expanding properly. My fix is slightly different: #62 |
Open
[sc-74538]
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some fixes are suggested:
imdsv2
feature, a few critical bugs require the fixes listed below.Description of changes:
IMDSV2
value is stored in the config file instead of a temporary environment variable.initialize
function calling to allow the function to use theIMDSV2
config parameter.eval
instead ofecho
in theget_metadata()
function.resource-id
tag is added.--tag-specification
tag to--tag-specifications
.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.