Skip to content

Commit fe6b5a6

Browse files
authored
Merge pull request 99designs#185 from sjauld/spoof-instance-id
spoof an instance ID so we can pass the go aws-sdk Available() call
2 parents 49c3e1a + dc6af17 commit fe6b5a6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/server.go

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func StartMetadataServer() error {
2929
router := http.NewServeMux()
3030
router.HandleFunc("/latest/meta-data/iam/security-credentials/", indexHandler)
3131
router.HandleFunc("/latest/meta-data/iam/security-credentials/local-credentials", credentialsHandler)
32+
// The AWS Go SDK checks the instance-id endpoint to validate the existence of EC2 Metadata
33+
router.HandleFunc("/latest/meta-data/instance-id/", instanceIdHandler)
3234

3335
l, err := net.Listen("tcp", metadataBind)
3436
if err != nil {
@@ -63,6 +65,10 @@ func credentialsHandler(w http.ResponseWriter, r *http.Request) {
6365
io.Copy(w, resp.Body)
6466
}
6567

68+
func instanceIdHandler(w http.ResponseWriter, r *http.Request) {
69+
fmt.Fprintf(w, "aws-vault")
70+
}
71+
6672
func checkServerRunning(bind string) bool {
6773
_, err := net.DialTimeout("tcp", bind, time.Millisecond*10)
6874
return err == nil

0 commit comments

Comments
 (0)