r/awslambda • • Mar 10 '21

Should I use AWS Lambda for this?

3 Upvotes

I'm building a mobile app that is heavily based around Socket.IO--Right now the community is small, but hopefully it will grow fast. I need to set up an AWS server to host the SocketManager on. The way the socket works in my app is 2 people join a room, and then send data every 3-ish seconds to the other user. What would be the best AWS Service to use? I know EC2 is one of the most widely used services, although I think Lambda might be better suited for this, but I've never used AWS before so I really don't know which ones are the best for sockets. If I can provide any more information to help you help me, let me know--thank you!


r/awslambda • • Feb 18 '21

Modifying Values in Pass States in Step Functions

3 Upvotes

Good Afternoon All,

I have created a simple POC to demonstrate this issue and the State Machine definition can be found below.

My goal is to have a Pass state that modifies certain values inside the input data while leaving the rest as is. I have read through the majority of the documentation and according to the documentation I am doing this correctly. The Step Function starts off with the following the data input :

{
  "SpecialVariables": {
    "PreviousValueTest": "ABC123",
    "StringTest": "a random input string",
    "BoolTest": true,
    "IntTest": 0
  },
  "SomeRandomData": [
    {
      "DataStuff": 1
    }
  ]
}

The first state simply passes this to the next state. In the next state it is supposed to change all values in SpecialVariables except for PreviousValueTest. However, in the output of the second state you can see the following :

{
  "SpecialVariables": {
    "PreviousValueTest.$": "$.SpecialVariables.PreviousValueTest",
    "StringTest": "a random string",
    "BoolTest": false,
    "IntTest": 1
  },
  "SomeRandomData": [
    {
      "DataStuff": 1
    }
  ]
}

I assume that there is a simple explanation as to what exactly I am doing terribly wrong. Any information you can provide would be greatly appreciated.

Thanks!

State Machine Definition

{
  "Comment": "A Hello World example of the Amazon States Language using Pass states",
  "StartAt": "Hello",
  "States": {
    "Hello": {
      "Type": "Pass",
      "Next": "World"
    },
    "World": {
      "Type": "Pass",
      "Result": {
        "PreviousValueTest.$": "$.SpecialVariables.PreviousValueTest",
        "StringTest": "a random string",
        "BoolTest": false,
        "IntTest": 1
      },
      "ResultPath": "$.SpecialVariables",
      "End": true
    }
  }
}

r/awslambda • • Jan 27 '21

Python functions in Lambda

3 Upvotes

Anyone have any recommended courses or readings for writing python scripts/code for aws lambdas and beyond?


r/awslambda • • Jan 17 '21

Running AWS Lambda written in Java with Docker

Thumbnail
sopin.dev
3 Upvotes

r/awslambda • • Jan 14 '21

Malformed Lambda proxy response - what causes it and how to fix it?

3 Upvotes

A problem that pops up frequently when building serverless applications with AWS API Gateway and AWS Lambda is:

Execution failed due to configuration error: Malformed Lambda proxy response.

What causes it and how to fix it: https://dashbird.io/blog/malformed-lambda-proxy-response/


r/awslambda • • Jan 09 '21

Why is testing SNS > Lambda producing different results between the console and cli publish?

3 Upvotes

Hi, trying to put this as simply as possible if I test my lambda function via the CLI with

aws sns publish --message file://message.txt --subject CLItest --topic-arn ${npm_package_SNS_srcARN}

where message.txt is

{ "test": "cli",
  "length": "20",
  "width": "6"
}

the function code

        var jMsg = event.Records[0].Sns.Message

        var message = JSON.parse(jMsg);
        console.log('message: ', message);
        console.log('message: ', message.test);

produces the following result

2021-01-08T23:41:58.594Z	612eb85a-238f-4e09-8248-f5ee9c8cbf30	INFO	message:  { test: 'cli', length: '20', width: '6' }
2021-01-08T23:41:58.594Z	612eb85a-238f-4e09-8248-f5ee9c8cbf30	INFO	message:  cli

For test two from the console I select AWS Console > Configure Test Event > Amazon SNS Test Notification and copy message.txt into the Message element (I have changed the value of test in order to differentiate the tests ), the Message is now as follows;

    "Message": {
      "test": "console",
      "length": "10",
      "width": "5"
    } 

In order to get the code working I have added the JSON.stringify () function as follows ;

        var jMsg = event.Records[0].Sns.Message

        var message = JSON.parse(JSON.stringify(jMsg));
        console.log('message: ', message);
        console.log('message: ', message.test);

Then I just press Test, to produce the following results;

2021-01-06T17:11:20.310Z	e8b4e36b-191b-44de-b0a0-5ae10c136d0b	INFO	message:  { test: 'console', length: '10', width: '5' }
2021-01-06T17:11:20.311Z	e8b4e36b-191b-44de-b0a0-5ae10c136d0b	INFO	message:  console

So the question is why do I need to add JSON.stringify() to get it working, can someone explain what's happening and how to change the code/message so that it always works?

Cheers

Chris


r/awslambda • • Jan 03 '21

Best Practices on Return / Exit Codes?

3 Upvotes

Good Evening,
I'm relatively new to writing AWS Lambdas, and I've been writing some in Python lately.

My lambdas are generally structured where the handler function instantiating another class which calls a method to actually do the logic of the Lambda, which seems typical. Once this logic is done, it returns to the handler function and then exits. For perspective, these are lambdas that are invoked by an S3 event, do some file processing, insert data into a DB, and then exit.

I'm wondering if there are guidelines/tips/best practices on what the handler function should return, depending on whether there was a success or not. Additionally, having actual return code/exit codes would make testing easier, I imagine. I've seen some people use like HTTP Status codes returned as a dictionary, but I'm not sure if there's any benefit to that.

TLDR: Is there a standard or best practice for return/exit codes from AWS Lambdas - Success or Failures?


r/awslambda • • Dec 29 '20

AWS lambda WebSocket functionality (Python)

3 Upvotes

I have uploaded a zip-based lambda function with a custom library that is using websocket functionality. I'm wondering if it's even possible to access a websocket from a lambda function.

Im running this code out of a proxy GET method (i dont think the method type matters?) that has 4 parameters.

If someone cant even point me in the right direction of how to get the Test event working for this function, i might be able to figure this out. Its throwing an error that is very hard to make out.

The error handling on lambda is abysmal. I feel like I would have been able to figure this out myself if it was better which is why I'm here.


r/awslambda • • Dec 06 '20

Webinar on managing workflows with STEP FUNCTIONS

3 Upvotes

Hi Folks,
I'm happy to share with you a new joint blog post with our amazing partners at Cloudway on how to manage Serverless workflows with Step Functions.
https://lumigo.io/blog/managing-serverless-flows-with-aws-step-functions/

If you'd like a drill-down and a live demo (plus a brand new t-shirt), you're welcome to join our joint webinar this upcoming Thursday, Dec 10 AM, at 10:00 PT. You can register here-
-https://info.lumigo.io/webinar-lambda-step-functions

Looking forward to seeing you.


r/awslambda • • Nov 08 '20

Debugging AWS Lambda Timeouts | Lumigo

Thumbnail
lumigo.io
3 Upvotes

r/awslambda • • Nov 05 '20

How we reduced Lambda cold starts at ACG

Thumbnail
acloudguru.com
3 Upvotes

r/awslambda • • Sep 10 '20

How to invoke HTTP from Lambda without waiting.

3 Upvotes

r/awslambda • • Jun 14 '20

A look at Access Keys in AWS Lambda

Thumbnail
keithrozario.com
3 Upvotes

r/awslambda • • Jun 02 '20

Working with AWS Lambda and SQS

Thumbnail
loginradius.com
3 Upvotes

r/awslambda • • Apr 15 '20

Has anyone created AWS lex Chatbot? If yes how did you deploy the BOT?

3 Upvotes

r/awslambda • • Jan 29 '20

Blog Post: How to Set Up an AWS Lambda PowerShell Function

3 Upvotes

Hello everyone, Michael Soule just wrote a shiny new blog post you may enjoy on the ATA blog.

Summary: Curious how you can leverage AWS Lambda PowerShell functions in your environment? Learn how in this step-by-step tutorial.

https://adamtheautomator.com/aws-lambda-powershell/


r/awslambda • • Nov 15 '19

My talk on writing efficient and effective code for Python on Lambda.

Thumbnail
youtu.be
3 Upvotes

r/awslambda • • Sep 19 '19

Great guide for lowering your Lambda Costs

3 Upvotes

r/awslambda • • Jul 07 '19

If anyone is looking for a step-by-step guide on how to set up a Kubernetes cluster with built-in Knative while enjoying a Lambda-like experience, here's a great how-to

3 Upvotes

r/awslambda • • Jun 21 '19

How to improve AWS Lambda Cold Start performance

Thumbnail
lumigo.io
3 Upvotes

r/awslambda • • May 13 '19

How to do sequential processing with AWS Lambda/SQS

Thumbnail
github.com
3 Upvotes

r/awslambda • • Mar 10 '19

3 Tips to control AWS Lambda costs

3 Upvotes

r/awslambda • • Feb 25 '19

Use Lambda Layers To Post to Slack For Errors, Alerts, or Anything You Want!

Thumbnail
medium.com
3 Upvotes

r/awslambda • • Feb 11 '19

AWS Lambda and Secret Management (x-post /r/aws)

Thumbnail
reddit.com
3 Upvotes