aws-sam-cli
aws-sam-cli copied to clipboard
AWS::Serverless::Function not using defined API Gateway
Hi
I am trying to test a function locally with SAM CLI that has a api-gateway defined. When I execute sam local start-api I the endpoint is successfully available:
Mounting V1GetStores at http://127.0.0.1:3000/stores [GET]
But when i look at the APIGatewayProxyRequest and lamda context is does not reflect my configurations. My stage name v1 and not prod. How could I verify that the api I have defined is used by my function correctly?
API
V1ThisApi: Type: 'AWS::Serverless::Api' Properties: StageName: v1 paths: "/stores": get:
Function
Events: ProxyApiRoot: Type: Api Properties: RestApiId: !Ref V1ThisApi Path: /stores Method: get
**ILambdaContext**
{
"FunctionName": "test",
"FunctionVersion": "$LATEST",
"LogGroupName": "/aws/lambda/test",
"LogStreamName": "2018/06/21/[$LATEST]40d77c1030dd556b",
"MemoryLimitInMB": 1024,
"AwsRequestId": "3e5a3343-08e3-4a7e-ba94-cd7df18d197a",
"InvokedFunctionArn": "arn:aws:lambda:ap-southeast-2:000000000000:function:test",
"RemainingTime": "00:00:29.6172565",
"ClientContext": {
"Client": null,
"Custom": null,
"Environment": null
},
"Identity": {
"IdentityId": "",
"IdentityPoolId": ""
},
"Logger": {}
}
**APIGatewayProxyRequest**
{
"Resource": "/stores",
"Path": "/stores",
"HttpMethod": "GET",
"Headers": {
"Accept-Encoding": "gzip, deflate",
"X-Forwarded-Port": "3000",
"Connection": "keep-alive",
"X-Retail-Account": "",
"User-Agent": "PostmanRuntime/7.1.5",
"Host": "127.0.0.1:3000",
"X-Forwarded-Proto": "http",
"X-Api-Key": "",
"Accept": "application/json",
"Cache-Control": "no-cache",
"Postman-Token": "fca8d9aa-1110-47ec-8214-319778cc08de"
},
"QueryStringParameters": null,
"PathParameters": null,
"StageVariables": null,
"RequestContext": {
"Path": "/stores",
"AccountId": "123456789012",
"ResourceId": "123456",
"Stage": "prod",
"RequestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"Identity": {
"CognitoIdentityPoolId": null,
"AccountId": null,
"CognitoIdentityId": null,
"Caller": null,
"ApiKey": null,
"SourceIp": "127.0.0.1",
"CognitoAuthenticationType": null,
"CognitoAuthenticationProvider": null,
"UserArn": null,
"UserAgent": "Custom User Agent String",
"User": null
},
"ResourcePath": "/stores",
"HttpMethod": "GET",
"ApiId": "1234567890",
"Authorizer": null
},
"Body": null,
"IsBase64Encoded": false
}
Duplicate of #292
Closing