Home > Mobile >  AWS Parameters and Secrets Lambda Extension throwing 400 Bad Request
AWS Parameters and Secrets Lambda Extension throwing 400 Bad Request

Time:01-26

We have been trying to use the AWS Parameters and Secrets Lambda Extension with one of our .NET 6 Lambdas.

The region is us-east-1 and the version of the extension is 1.0.103.

The requests to the extension are returning 400 (Bad Request).

The HTTP client is initialized with the correct header:

var _httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Add("X-AWS-Parameters-Secrets-Token", Environment.GetEnvironmentVariable("AWS_SESSION_TOKEN"));

and the request is sent to the following URL:

http://localhost:2773/secretsmanager/get?secretId={MY-SECRET-NAME}

We have verified that the execution role of Lambda has permission to read from Secrets Manager and that the secret name is valid, by manually using the .NET SDK.

CodePudding user response:

The header X-AWS-Parameters-Secrets-Token is case-sensitive & needs to be set to X-Aws-Parameters-Secrets-Token.

This is resulting in a 400 Bad Request response (strangely, as I would expect a 401 Unauthorized response, in this case, to hint at the header not being interpreted correctly).

Try replacing:

_httpClient.DefaultRequestHeaders.Add("X-AWS-Parameters-Secrets-Token", Environment.GetEnvironmentVariable("AWS_SESSION_TOKEN"));

with:

_httpClient.DefaultRequestHeaders.Add("X-Aws-Parameters-Secrets-Token", Environment.GetEnvironmentVariable("AWS_SESSION_TOKEN"));

  • Related