From ef03b3cf476ba103d4d71babeca6b5f0f37ed9f4 Mon Sep 17 00:00:00 2001 From: Amit Saha Date: Sun, 2 Sep 2018 10:47:18 +1000 Subject: [PATCH 1/2] Add handler for iam/info --- server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/server.go b/server/server.go index c5133a271..ca82e1294 100644 --- a/server/server.go +++ b/server/server.go @@ -29,6 +29,8 @@ func StartMetadataServer() error { } router := http.NewServeMux() + // The AWS .NET SDK checks this endpoint during obtaining credentials/refreshing them + router.HandleFunc("/latest/meta-data/iam/info/", infoHandler) router.HandleFunc("/latest/meta-data/iam/security-credentials/", indexHandler) router.HandleFunc("/latest/meta-data/iam/security-credentials/local-credentials", credentialsHandler) // The AWS Go SDK checks the instance-id endpoint to validate the existence of EC2 Metadata @@ -47,6 +49,11 @@ type metadataHandler struct { http.Handler } +func infoHandler(w http.ResponseWriter, r *http.Request) { + var jsonStr = []byte(`{"Code" : "Success"}`) + fmt.Fprintf(w, string(jsonStr)) +} + func indexHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "local-credentials") } From 3e646abb6b8a853cd5779e6d1dcc60a61ef37a8d Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Mon, 3 Sep 2018 09:18:36 +1000 Subject: [PATCH 2/2] Rename function to indicate it's a stub --- server/server.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/server.go b/server/server.go index ca82e1294..7c1bbca8e 100644 --- a/server/server.go +++ b/server/server.go @@ -29,12 +29,12 @@ func StartMetadataServer() error { } router := http.NewServeMux() - // The AWS .NET SDK checks this endpoint during obtaining credentials/refreshing them - router.HandleFunc("/latest/meta-data/iam/info/", infoHandler) router.HandleFunc("/latest/meta-data/iam/security-credentials/", indexHandler) router.HandleFunc("/latest/meta-data/iam/security-credentials/local-credentials", credentialsHandler) // The AWS Go SDK checks the instance-id endpoint to validate the existence of EC2 Metadata router.HandleFunc("/latest/meta-data/instance-id/", instanceIdHandler) + // The AWS .NET SDK checks this endpoint during obtaining credentials/refreshing them + router.HandleFunc("/latest/meta-data/iam/info/", infoHandlerStub) l, err := net.Listen("tcp", metadataBind) if err != nil { @@ -49,9 +49,8 @@ type metadataHandler struct { http.Handler } -func infoHandler(w http.ResponseWriter, r *http.Request) { - var jsonStr = []byte(`{"Code" : "Success"}`) - fmt.Fprintf(w, string(jsonStr)) +func infoHandlerStub(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, `{"Code" : "Success"}`) } func indexHandler(w http.ResponseWriter, r *http.Request) {