简体   繁体   中英

AWS Parameters and Secrets Lambda Extension throwing 400 Bad Request

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.

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM