Skip to content

Commit 1fcb12b

Browse files
committed
aws/ec2rolecreds: Fix security creds path to include trailing slash
Fixes the iamSecurityCredsPath var to include a trailing slash preventing redirects when making requests to the EC2 Instance Metadata service. Fix aws#351
1 parent 1fdfcec commit 1fcb12b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

aws/ec2rolecreds/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type ec2RoleCredRespBody struct {
102102
Message string
103103
}
104104

105-
const iamSecurityCredsPath = "/iam/security-credentials"
105+
const iamSecurityCredsPath = "/iam/security-credentials/"
106106

107107
// requestCredList requests a list of credentials from the EC2 service.
108108
// If there are no credentials, or there is an error making or receiving the request

aws/ec2rolecreds/provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const credsFailRespTmpl = `{
3333

3434
func initTestServer(expireOn string, failAssume bool) *httptest.Server {
3535
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
36-
if r.URL.Path == "/latest/meta-data/iam/security-credentials" {
36+
if r.URL.Path == "/latest/meta-data/iam/security-credentials/" {
3737
fmt.Fprintln(w, "RoleName")
3838
} else if r.URL.Path == "/latest/meta-data/iam/security-credentials/RoleName" {
3939
if failAssume {

0 commit comments

Comments
 (0)