r/awslambda • • Aug 10 '20

⚡️ Dynatron - Bridge between AWS DynamoDB Document Client and Real World usage

2 Upvotes

This library is a result of years of working with AWS DynamoDB and overcoming underwater rocks, missing optimizations and hidden issues that are very hard to catch (like hanging SSL connections in 0.2% of cases).

Homepage - https://93v.github.io/dynatron/

Github - https://github.com/93v/dynatron

NPM Package - https://www.npmjs.com/package/dynatron


r/awslambda • • Aug 08 '20

How to trigger my python script in AWS?

2 Upvotes

I have a script that needs to run every time a specific email is sent with a specific attachment. I need to run this script using AWS.

I am wondering what the best way would be to:

  1. Trigger the script in AWS

  2. Access the CSV in the email attachment


r/awslambda • • Jun 15 '20

Serverless Architecture : Advantage of going Serverless for your next app development

Thumbnail
ateam-texas.com
2 Upvotes

r/awslambda • • May 23 '20

AWS Lambda and OracleDB integration

Thumbnail
rehanvdm.com
2 Upvotes

r/awslambda • • May 19 '20

S3 bucket creation date headache

2 Upvotes

Hey,

This little snippet really makes me scratching my head:

import boto3

bucket = os.environ['BUCKET_NAME']
s3 = boto3.resource('s3')
print(s3.Bucket(BUCKET_NAME).creation_date)

Running from the CLI it gives the proper creation date of the bucket. However, if I run it as a lambda function the result is null.

the lambda version:

import json
import base64
import boto3

BUCKET_NAME = os.environ['BUCKET_NAME']


def lambda_handler(event, context):

  s3 = boto3.resource('s3')
  
  print(s3.Bucket(BUCKET_NAME).creation_date)

  return {
    'statusCode': 200,
    'isBase64Encoded': 'false',
    'headers': { 'Content-Type': 'application/json' },
    'body': json.dumps({ 'bucket date': s3.Bucket(BUCKET_NAME).creation_date })
  }

r/awslambda • • May 05 '20

May 22, Free ACM TechTalk with Luke Closs on AWS Lambda

2 Upvotes

On May 22, join Luke Closs, Founder of ReCollect Systems, for the free ACM TechTalk "Integrating AWS Lambda with Your Majestic Monolith."

In this talk, you'll learn what AWS Lambda is and how it can be useful as you evolve the architecture of your applications. We'll cover an overview of the technology, where and when you should consider using it, and practical considerations for deployment.

Register here.


r/awslambda • • Apr 23 '20

Is it possible to pre-load an SNS queue to test Lambda parallelism?

2 Upvotes

I want to see how many messages my SNS/LAMBDA/DYNAMODB set up will process and the simplest way to test this would be to stop the subscriber (LAMBDA function ) from processing until the queue is loaded and then set it off. I've looked at the documentation but nothing obviously matches my requirements? Kind regards Chris


r/awslambda • • Apr 02 '20

Parsing error: Unexpected token

2 Upvotes

First-time Lambda user

I'm trying to get an IOT device payload from IOT Core to a GraphQL endpoint by using an 'Act' with a Lambda function on IOT Core.

I found the below tutorial online and tailored it to my needs but I get a "Parsing error: Unexpected token client" error.

https://aws.amazon.com/blogs/mobile/iot-with-aws-appsync/

I have also included the SQL statement used to select the data from the IOT Payload

SELECT 
dev_id AS trackerID,
timestamp() AS time, 
parse_time("MM.dd.yyyy HH:mm:ss z", timestamp(), "Europe/Belfast") AS date_time, 
counter, 
payload_fields.gps_1.altitude AS altitude, 
payload_fields.gps_1.latitude AS latitude, 
payload_fields.gps_1.longitude AS longitude, 
payload_fields.analog_in_5 AS batt, 
payload_fields.analog_in_6 AS kmph, 
payload_fields.analog_in_7 AS hdop,  
hardware_serial, 
metadata 
FROM '#'

and a screenshot of the Lambda function

Any assistance or suggestions would be appreciated!!!


r/awslambda • • Mar 18 '20

Lambda parallel execution

2 Upvotes

I'm newbie to Aws lambda with python runtime. Need your support on creating lambda function as mentioned below

I want my lambda to execute from one account to 500 cross account (details stored in dynamodb) in a a batch of 100 using 5 invokations. Is it possible?

100x5 = 500 accounts it should be executed. I'm able to execute my lambda functionality in one cross account. Not sure how can I do it for multiple accounts.

I'm not an expert level in python. So, please guide me


r/awslambda • • Mar 02 '20

AWS Lambda Downloading CSV?

2 Upvotes

I have a simple AWS Lambda doing two calls - One to SWAPI (Star Wars API) and one to the NASDAQ website. Both work locally, but in AWS Lambda, only the SWAPI call resolves and the NASDAQ call hangs until the Lambda function times out. Is it possible that the NASDAQ website is blocking the call? How can I confirm this? (Note: no errors show up when running, just hanging).

Here is the code:

import axios from "axios";

// If this is to be invoked directly, we can create our own event
export interface Event {
  name: string;
}

const main = async (): Promise<string> => {
  try {
    console.log(
      (
        await axios({
          url: "https://swapi.co/api/people/2",
          method: "GET",
          responseType: "blob"
        })
      ).data
    );

    console.log(
      (
        await axios({
          url:
            "https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download",
          method: "GET",
          responseType: "blob"
        })
      ).data
    );

    return "Success";
  } catch (e) {
    return `Failed + ${e}`;
  }
};

export { main };

r/awslambda • • Feb 13 '20

Serverless CI/CD ‘How To’ Series #1: A Guide to Preview Deployments with Serverless CI/CD

2 Upvotes

ICYMI, last week we launched Serverless CI/CD – the CI/CD service optimized for serverless workflows. This week we’re kicking off our Serverless CI/CD ‘How To’ blog series. Up first is “A Guide to Preview Deployments with Serverless CI/CD”. Learn how Preview Deployments enable you to automatically test and deploy a preview version of your service for every pull request – allowing your team to test, collaborate, and move faster.

With Serverless CI/CD Preview Deployments you can:

  • Automate Testing: Run Safeguards and automate tests before the staging environment.

  • Supplement Existing CI/CD: Use this in addition to whatever existing CI/CD tools you have.

  • Keep a Clean Environment for Code Review: Because the preview branch is discrete from other environments your reviewers don't have to worry about stepping on any toes.

  • Automate spin up and spin down: Resources are spun up automatically. Then configure your deployment to automatically remove the infrastructure resources created in AWS.

Check out our step by step guide and get started for free today!


r/awslambda • • Feb 11 '20

Dynamodb stream lambda trigger data being received is missing a field

2 Upvotes

The dynamodb has 23 fields but what we received is only 22 fields on the lambda trigger event there is a missing attribute being received by the lambda function.

Anyone has a lead for this?


r/awslambda • • Dec 13 '19

Sending (not replying to) a text from Lambda

2 Upvotes

Hello, I have set up a webhook to some python code on an aws lambda which can receive a text sent to a twilio number, and based on that text, REPLY with different messages.

Its easy, I simply return some specific XML from the lambda_handler(event, context) function.

What I can't do is, based on the body of the text, initiate a NEW text to person B. I'd like something like this,

  1. Person A sends SMS to Twilio# with the sms body of 'A'

  2. Twilio Number sends SMS to Person B with the sms body 'A says hello'

I can work out all the logic, I just can't figure out how to send a txt other than as a return statement from my lambda_handler function. Any help would be great!

Edit; This is generally what I used: https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-python-amazon-lambda


r/awslambda • • Dec 11 '19

Help in publishing rekognition values to SNS

2 Upvotes

Hello,

I am a newbee to python and programming languages. I am working on a small system on aws that includes services such as lambda, s3, sns, rekognition and cloudwatch. Aim of the system is to get the values for the jpg. images uploaded into s3.

I have written a lambda function which is given below but, the values are generated in cloudwatch but I am not sure how to get the values published into SNS subscription. Any help would be appreciated.

from future import print_function

import boto3 from decimal import Decimal import json import urllib

print('Loading function')

rekognition = boto3.client('rekognition')

def detect_labels(bucket, key): response = rekognition.detect_labels(Image={"S3Object": {"Bucket": bucket, "Name": key}})

return response

def lambda_handler(event, context):

bucket = event['Records'][0]['s3']['bucket']['name']
key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'].encode('utf8'))
try:
    
    
    response = detect_labels(bucket, key)


    print(response)

    return response
except Exception as e:
    print(e)
    print("Error processing object {} from bucket {}. ".format(key, bucket) +
          "Make sure your object and bucket exist and your bucket is in the same region as this function.")
    raise e

P.s I've tried including sns publish but not sure how the values generated in cloudwatch can be defined in the lambda function so that they get published to sns


r/awslambda • • Dec 04 '19

[help] Python lambda webscraper with selenium

2 Upvotes

Hi folks

I'm hoping someone here has set up or maintained a lamba function that webscrapes.

I'm open to other languages but have been using python.

I've googled and run every guide online and cloned a bunch of repos but they all appear to be outdated and no longer functional. My most recent error is that chrome webdriver doesn't have executable permissions. Even after chmod commands had been run.

Does anyone have a working lambda example or repo I could look into?

Thanks


r/awslambda • • Nov 16 '19

A Quickstart Guide to AWS Cognito, Lambda and SES (x-post /r/node)

Thumbnail
epsagon.com
2 Upvotes

r/awslambda • • Oct 11 '19

How are you QA Testing Lambda solutions?

2 Upvotes

I would like to know how people are testing AWS Lambda solution in terms of:

a. Manual testing:

Since Lambda function incur a charge per each request. How will QA offload these charges against the thousand of api calls they would make to thoroughly test an app?

What tools are available for manual testing lamda apps?

b. Test automation

- what tools are available for this?

I am new to this area.


r/awslambda • • Sep 25 '19

Do you want to know how Lambda performs in comparison to Azure and Google?

2 Upvotes

We wanted to know the answer to this question as well - that's why we created FaaSbenchmaerk and Faastest.com.

FaaSbenchmark is an open-sourced framework written in Go to benchmark FaaS platforms' performance accurately.

FaaStest.com is a website in which FaaS platforms' performance and benchmark tests are presented and can be analyzed easily. The benchmark results on FaaSTest are measured once a week using FaaSbenchmark.

The first release of FaaStest only supports AWS, Azure, and GCP, but we are inviting you to add new test cases and FaaS providers, using the open-source framework.


r/awslambda • • Aug 26 '19

Good to Go: Getting Started with AWS Lambda and Go

Thumbnail
epsagon.com
2 Upvotes

r/awslambda • • Jul 30 '19

Waiting for a result from a lambda function

2 Upvotes

I'm working on a c# application and using AWS lambda functions in the backend. The lambda function is working correctly and i'm able to call it from the application. The part I'm having trouble with is getting the code to wait for the result from the lambda function to be returned before continuing. I've looked into using the async/await pattern but i'm getting compile errors because AmazonLambda.InvokeAsync returns null.

This is the code what is correctly invoking the function and prints out the response but I'd like to instead return the response to the calling method. I've also tried changing the return from void to string and adding a return to the callback function but I get this error: "Anonymous function converted to a void returning delegate cannot return a value"

Any help is appreciated.

public void Invoke() {

InvokeRequest invokeRequest = new InvokeRequest() {

FunctionName = FunctionName,

Payload = Payload

};

Client.InvokeAsync(invokeRequest, responseObject => {

if (responseObject.Exception == null) {

Debug.Log("LAMBDA SUCCESS: " + Encoding.ASCII.GetString(responseObject.Response.Payload.ToArray()));

} else {

Debug.Log("LAMBDA ERR: " + responseObject.Exception);

}

});

}


r/awslambda • • Jul 30 '19

AWS Lambda Tutorial for Beginners

2 Upvotes

AWS Lambda is a service that computes the code and works without managing any server. It takes cost if the code runs, but if the code is not running; they take no cost for it.

https://www.tutorialandexample.com/aws-lambda-tutorial


r/awslambda • • Jul 10 '19

Unit Test Serverless Applications The DevOps Way — Part 1

Thumbnail
medium.com
2 Upvotes