From c0162457bf04b8bac5b4ca01282b61d3ff29cdc0 Mon Sep 17 00:00:00 2001 From: Patryk Kalinowski Date: Mon, 23 Sep 2024 12:18:25 +0200 Subject: [PATCH] rpc/awscreds: fail on unexpected status from instance profile name endpoint --- rpc/awscreds/provider.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rpc/awscreds/provider.go b/rpc/awscreds/provider.go index 48d5de3b..597125f1 100644 --- a/rpc/awscreds/provider.go +++ b/rpc/awscreds/provider.go @@ -100,6 +100,10 @@ func (p *Provider) getInstanceProfileName(ctx context.Context) (string, error) { } defer res.Body.Close() + if res.StatusCode != http.StatusOK { + return "", fmt.Errorf("unexpected status: %s", res.Status) + } + b, err := io.ReadAll(res.Body) if err != nil { return "", fmt.Errorf("reading response body: %w", err)