From 5b962c57489f6995f24c56fc4ac8b97faec753fd Mon Sep 17 00:00:00 2001 From: Jeeyoung Kim Date: Tue, 20 Mar 2018 05:34:54 -0700 Subject: [PATCH] Revert "Feature: Allow getting credentials via EC2 role (#3343)" (#3985) This reverts commit 808f79f00aab29cd6464c71b120105765533c4c7. --- discovery/ec2/ec2.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/discovery/ec2/ec2.go b/discovery/ec2/ec2.go index 51500e633..aba03066c 100644 --- a/discovery/ec2/ec2.go +++ b/discovery/ec2/ec2.go @@ -22,7 +22,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" @@ -186,16 +185,6 @@ func (d *Discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group) { } } -func (d *Discovery) ec2MetadataAvailable(sess *session.Session) (isAvailable bool) { - svc := ec2metadata.New(sess, &aws.Config{ - MaxRetries: aws.Int(0), - }) - - isAvailable = svc.Available() - - return isAvailable -} - func (d *Discovery) refresh() (tg *targetgroup.Group, err error) { t0 := time.Now() defer func() { @@ -218,12 +207,7 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) { creds := stscreds.NewCredentials(sess, d.roleARN) ec2s = ec2.New(sess, &aws.Config{Credentials: creds}) } else { - if d.aws.Credentials == nil && d.ec2MetadataAvailable(sess) { - creds := ec2rolecreds.NewCredentials(sess) - ec2s = ec2.New(sess, &aws.Config{Credentials: creds}) - } else { - ec2s = ec2.New(sess) - } + ec2s = ec2.New(sess) } tg = &targetgroup.Group{ Source: *d.aws.Region,