sk94
sk94

Reputation: 11

TCP/IP Communication in AWS

I want to implement basic TCP/IP protocol using AWS Lambda functions. If we consider client as one AWS lambda function and server as another AWS Lambda function(not sure whether we can assume client ans server as lambda functions) can we establish client-server communication between the two lambda functions using TCP/IP protocol.(This is different from calling one lambda function from another).Also i want to know whether the client or server side socket programming code written in java can be converted to aws lambda function in java?

Upvotes: 1

Views: 2763

Answers (2)

jRapp3r
jRapp3r

Reputation: 33

AWS Lambda is basically a container running your application in the backend. In order to establish a socket connection between two Lambdas, you will have to explore using API Gateway's Websockert APIs.

It is possible to have a TCP/IP connection between two Lambda containers provided you are calling those functions via an API G/w websocket connection.

Hope this helps!

Reference:

  1. https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html
  2. https://codeburst.io/how-to-build-a-react-chat-app-with-aws-api-gateway-websockets-and-cognito-custom-authorizer-6f84f2da47ec
  3. https://github.com/aws-samples/simple-websockets-chat-app/blob/master/template.yaml

Upvotes: 3

keithRozario
keithRozario

Reputation: 406

Using Lambda as a client to access a server is trivial, you can easily create most types of TCP connections from a Lambda outwards.

However, inwards is far more tricky, as Lambda operates a container, and you are a low-privilege user in this container. So low privilege that you cannot bind to a port and expose that. Also, lambda by default operate on AWS VPC, and are behind a NAT.

There are some solutions out there, notably this: https://read.acloud.guru/https-medium-com-timawagner-serverless-networking-the-next-step-in-serverless-evolution-95bc8adaa904

But in short, what inter-communication between two lambda functions via TCP is a pretty difficult thing to accomplish without some 3rd-party tools and/or some servers in-between.

I made this repo, that allows a reverse shell into a lambda, you might also be interested in it: https://github.com/keithrozario/Lambshell

Upvotes: 4

Related Questions