Comments (6)
@yosriady Yes that is possible. . A remote lambda running on AWS, no.
(edited) The following is an example of invoking a running go binary via RPC. You could for example use this to pprof / benchmark / test your binary before deployment...
The invoke method signature is defined at:
aws-lambda-go/lambda/function.go
Line 24 in 64efb26
- Server
package main
import (
"os"
"github.com/aws/aws-lambda-go/lambda"
)
func hello() (string, error) {
return "Hello λ!", nil
}
func main() {
// the _LAMBDA_SERVER_PORT environment would normally be provided externally
os.Setenv("_LAMBDA_SERVER_PORT", "9988")
lambda.Start(hello)
}
- Client
package main
import (
"fmt"
"log"
"net/rpc"
"github.com/aws/aws-lambda-go/lambda/messages"
)
func main() {
c, err := rpc.Dial("tcp", "127.0.0.1:9988")
if err != nil {
log.Fatalln(err)
}
var result messages.InvokeResponse
request := &messages.InvokeRequest{}
err = c.Call("Function.Invoke", request, &result)
if err != nil {
log.Fatal(err)
}
if result.Error != nil {
log.Fatal(result.Error.Message)
}
fmt.Println("Function.Invoke =", string(result.Payload))
}
from aws-lambda-go.
@yosriady I'm guessing you mean invoking the uploaded Lambda function?
You are not limited to using API Gateway to Invoke your Lambda Function. You may also the AWS SDK for Go (or any language) to invoke your Lambda Function directly. https://github.com/aws/aws-sdk-go https://docs.aws.amazon.com/sdk-for-go/api/service/lambda/#Lambda.Invoke
from aws-lambda-go.
@mlctrez
How would rpc.Dial("tcp", "127.0.0.1:9988")
work? Wouldn't you need to connect to the IP of the Lambda function?
from aws-lambda-go.
Yes, I'd like to invoke my Lambda function via both HTTP and RPC if possible.
I'm aware that we can invoke it using the AWS Lambda SDK.
from aws-lambda-go.
@yosriady
I read your question as wanting to test a go lambda binary locally. That was an incorrect assumption on my part.
For a Lambda running on AWS, the RPC IP and Port are not accessible outside of the AWS Lambda infrastructure.
from aws-lambda-go.
To go with @mlctrez comments:
From https://aws.amazon.com/lambda/faqs/
Q: What restrictions apply to AWS Lambda function code?
Lambda attempts to impose as few restrictions as possible on normal language and operating system activities, but there are a few activities that are disabled: Inbound network connections are blocked by AWS Lambda, and for outbound connections only TCP/IP sockets are supported, and ptrace (debugging) system calls are blocked. TCP port 25 traffic is also blocked as an anti-spam measure.
from aws-lambda-go.
Related Issues (20)
- BUG: `lambdaurl.Wrap` does not add `Content-Type` or `Content-Length` headers like `http.ResponseWriter` does HOT 3
- how to authenticate to eks from a lambda HOT 1
- DynamoDBAttributeValue.String() accessor method inconsistent with documented behavior
- Don't output to stdout directly HOT 2
- Unable to set options (`UseNumber` & `DisallowUnknownFields()`) on the json decoder HOT 2
- Method with signature events.APIGatewayProxyRequest and events.APIGatewayProxyResponse doesn't invoke Http API
- Lambda Event to support Lex V2 API
- feat: Add support for AWS VPC Lattice events
- The generic handler is slower than the dynamic handler
- Support for `AWS_LAMBDA_EXEC_WRAPPER`
- S3ObjectLambdaEvent is missed in codebase
- events.CodeCommitReference has missing Deleted field HOT 2
- ALB target grouped Lambda returns fine but alb return 502 error that "LambdaInvalidResponse" HOT 2
- Deserialisation of array values in Cognito events custom UserAttributes not working correctly HOT 1
- Support structured JSON logging for errors HOT 2
- please add a mocked example HOT 1
- Custom runtime provided.al2 broken on v1.42 HOT 1
- Add IoTCoreMQTTMessage to aws/aws-lambda-go/events
- Add disconnectStatusCode to event/APIGatewayWebsocketProxyRequestContext
- RequestContext.Authorizer differs between REST gateway vs HTTP gateway
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-go.