From 855d7d1bda815fcf65f8b0e938e7dd831b772005 Mon Sep 17 00:00:00 2001 From: Boris Petersen Date: Mon, 18 Jul 2022 11:33:52 +0200 Subject: [PATCH] fix assume role when running in ECS. (#2876) This fixes #2875 Signed-off-by: Boris Petersen --- lib/awsapi/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/awsapi/config.go b/lib/awsapi/config.go index f111b7b64..e10d84736 100644 --- a/lib/awsapi/config.go +++ b/lib/awsapi/config.go @@ -204,7 +204,11 @@ func (cfg *Config) getAPICredentials() (*credentials, error) { } if ecsMetaURI := os.Getenv("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"); len(ecsMetaURI) > 0 { path := "http://169.254.170.2" + ecsMetaURI - return getECSRoleCredentialsByPath(cfg.client, path) + ac, err := getECSRoleCredentialsByPath(cfg.client, path) + if err != nil { + return nil, fmt.Errorf("cannot obtain ECS role credentials: %w", err) + } + acNew = ac } // we need instance credentials if dont have access keys