Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
A lambda that returns a response which looks like this (ts type APIGatewayProxyStructuredResultV2
)
{
statusCode: 302,
headers: {
Location: authorizationUrl,
},
cookies: [
"cookie1=value1; Path=/; HttpOnly; Secure; SameSite=None",
"cookie2=value2; Path=/; HttpOnly; Secure; SameSite=None"
],
body: ''
};
only adds one Set-Cookie
header with a cookie that contains the joined value of all cookies in the array.
Expected Behavior
In the response, each cookie in the array becomes a set-cookie header as per the AWS docs: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-lambda-response-format
This is what occurs when I am deployed on AWS but no when I deploy with localstack
How are you starting LocalStack?
With the localstack
script
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack
command, arguments, or docker-compose.yml
)
`USE_SSL=1 localstack start`
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
My issue is from a CDK app running cdklocal deploy but here are some steps to replicate thanks to the robot overlord.
- Create the IAM role for Lambda
aws iam create-role \
--role-name lambda-exec-role \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "lambda.amazonaws.com" },
"Action": "sts:AssumeRole"
}
]
}' \
--endpoint-url https://localhost.localstack.cloud:4566
- Create the Lambda function
echo 'exports.handler = async () => ({
statusCode: 200,
cookies: [
"cookie1=value1; Path=/; HttpOnly; Secure; SameSite=None",
"cookie2=value2; Path=/; HttpOnly; Secure; SameSite=None"
],
body: "Set multiple cookies"
});' > index.js
zip function.zip index.js
aws lambda create-function \
--function-name set-cookie-test \
--runtime nodejs18.x \
--handler index.handler \
--role arn:aws:iam::000000000000:role/lambda-exec-role \
--zip-file fileb://function.zip \
--endpoint-url https://localhost.localstack.cloud:4566
- Create an HTTP API Gateway
aws apigatewayv2 create-api \
--name "SetCookieTestAPI" \
--protocol-type HTTP \
--target arn:aws:lambda:us-east-1:000000000000:function:set-cookie-test \
--endpoint-url https://localhost.localstack.cloud:4566
- Export API id for next step
export API_ID=your-api-id-here
- Add integration and route
aws apigatewayv2 create-integration \
--api-id $API_ID \
--integration-type AWS_PROXY \
--integration-uri arn:aws:lambda:us-east-1:000000000000:function:set-cookie-test \
--payload-format-version 2.0 \
--integration-method POST \
--endpoint-url https://localhost.localstack.cloud:4566
- Export the integration id for next step
export INTEGRATION_ID=your-integration-id-here
- Create the route
aws apigatewayv2 create-route \
--api-id $API_ID \
--route-key "GET /test" \
--target integrations/$INTEGRATION_ID \
--endpoint-url https://localhost.localstack.cloud:4566
- Deploy the API
aws apigatewayv2 create-deployment \
--api-id $API_ID \
--endpoint-url https://localhost.localstack.cloud:4566
- Test the endpoing
curl -i https://$API_ID.execute-api.localhost.localstack.cloud:4566/test
Environment
- OS: Mac OS 15.4.1
- LocalStack:
LocalStack version: 3.5.0
LocalStack Docker image sha: sha256:55a9ca4d50c31dbab0ea194a99aace23ce77f4806b9e4277b0055f1d3b6009a4
LocalStack build date: 2025-05-02
LocalStack build git hash:6acdef4e5
Anything else?
No response