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 GitHub
parent 814bb1685f
commit 2f9668eba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -204,7 +204,11 @@ func (cfg *Config) getAPICredentials() (*credentials, error) {
} }
if ecsMetaURI := os.Getenv("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"); len(ecsMetaURI) > 0 { if ecsMetaURI := os.Getenv("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"); len(ecsMetaURI) > 0 {
path := "http://169.254.170.2" + ecsMetaURI 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 // we need instance credentials if dont have access keys