fix assume role when running in ECS. (#2876)

This fixes #2875

Signed-off-by: Boris Petersen <boris.petersen@idealo.de>
This commit is contained in:
Boris Petersen 2022-07-18 11:33:52 +02:00 committed by Aliaksandr Valialkin
parent ce00b3862f
commit 855d7d1bda
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -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