LocalStack is neat, but it's hard to find documentation for it. I'm having trouble hitting my API Gateway proxy endpoint that's connected to a Lambda function.
The only things I can think of is when I did the put-integration for the gateway, I wasn't sure how to handle the credentials param (given this is 100% local... there's no real AWS account I'm using) so I left it commented for now:
aws --endpoint-url=http://localhost:4567 apigateway \
put-integration \
--region us-west-2 \
--rest-api-id 0091232159 \
--resource-id 3732709762 \
--http-method ANY \
--type AWS_PROXY \
--integration-http-method POST \
--uri arn:aws:lambda:us-west-2:000000000000:function:PostProposal \
#--credentials arn:aws:iam::123456789012:role/apigAwsProxyRole
And my coworker found a thread that make it sound like maybe it's a bug in LocalStack:
https://github.com/atlassian/localstack/issues/129
Anyway, here's what my API looks like when I do aws --endpoint-url=http://localhost:4567 apigateway get-resources --rest-api-id 0091232159
:
{
"items": [
{
"id": "3312801A-ZA-Z6",
"path": "/",
"resourceMethods": {
"GET": {}
}
},
{
"id": "3732709762",
"parentId": "3312801A-ZA-Z6",
"pathPart": "{proxy+}",
"path": "/{proxy+}",
"resourceMethods": {
"GET": {},
"ANY": {
"httpMethod": "ANY",
"authorizationType": "NONE",
"methodIntegration": {
"type": "AWS_PROXY",
"httpMethod": "ANY",
"uri": "arn:aws:lambda:us-west-2:000000000000:function:PostProposal",
"integrationResponses": {
"200": {
"statusCode": 200,
"responseTemplates": {
"application/json": null
}
}
}
}
}
}
}
]
}
My Lambda function is all set up and responds with a 200 when I do:
aws --endpoint-url=http://localhost:4574 lambda invoke --function-name PostProposal outfile.json
Now I just want to cURL an endpoint that will fire off the Lambda.
I found this thread: https://github.com/localstack/localstack/issues/229 which has a cURL example:
curl http://localhost:4567/restapis/35937034A-Z3/test/_user_request_/u-1234
And another one: https://bitbucket.org/atlassian/localstack/issues/4/how-to-create-api-gateway-deployments which has:
curl http://localhost:4567/restapis/$api_id/v1/_user_request_/mypath
I know my API ID and that 'v1' correlates to my 'test' stage name. My endpoint is at the root, so I don't think I need something where he's got bypath.
So I've tried all different variations of paths like this with GET and POST:
curl http://localhost:4567/restapis/0091232159/test/_user_request_/
I get various replies of 404, 500, and {"message": "Unable to find integration for path ...
.
I'm at least hitting the API Gateway simulated server; when I do curl -vv I see:
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET /restapis/0091232159/test/_user_request_/ HTTP/1.1
> Host: localhost:4567
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
Any ideas? I just need the magic path!