Skip to content

Commit

Permalink
Use 1s timeout for fetching imdsv2 token (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
saracen committed Mar 2, 2022
1 parent 1600e40 commit f2d40be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/credentials/iam_aws.go
Expand Up @@ -19,6 +19,7 @@ package credentials

import (
"bufio"
"context"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -254,7 +255,10 @@ func getEcsTaskCredentials(client *http.Client, endpoint string, token string) (
}

func fetchIMDSToken(client *http.Client, endpoint string) (string, error) {
req, err := http.NewRequest(http.MethodPut, endpoint+tokenPath, nil)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint+tokenPath, nil)
if err != nil {
return "", err
}
Expand Down

0 comments on commit f2d40be

Please sign in to comment.