Quantcast
Channel: Active questions tagged aws-lambda - Stack Overflow
Viewing all articles
Browse latest Browse all 3995

expected AWS Lambda environment variables [_LAMBDA_SERVER_PORT AWS_LAMBDA_RUNTIME_API] are not defined

$
0
0

I am trying to create a simple AWS Lambda function with GoLang that performs that performs an HTTP API request (GET) (API Gateway). I have the following functions and code snippets

in my main.go file these functions exist

package mainimport ("log""github.com/aws/aws-lambda-go/events""github.com/aws/aws-lambda-go/lambda")func main(){     lambda.Start(handler)}func handler (request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {    log.Printf("hello world")    response := events.APIGatewayProxyResponse{        StatusCode: 200,    Body: "hello world",    }    return response, nil}type User struct {    Username string `json:"username"`    Password string `json:"password"`}type ResponseBody struct {    Message string `json:"username"`}

With those methods in my **main.go ** file,I created an HTTP API on AWS and upload a built zipped version of my main.go source code after which I obtained the endpoint as well as the route but after testing it on Postman, I got the following response

{"message": "Internal Server Error"}

I double cross-cheked my endpoint and route but got no other response different from that above.I tried too the thunder client postman alternative extension on vscode but got the same response (505)

However, I decided to run my main.go source code using go run main.golocally on my terminal and I got the following error message

2023/04/04 15:08:55 expected AWS Lambda environment variables [_LAMBDA_SERVER_PORT AWS_LAMBDA_RUNTIME_API] are not defined exit status 1

I am missing something here? Please what to do? I am stuck.

I am using Ubuntu by the way (latest of date)


Viewing all articles
Browse latest Browse all 3995

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>