aws-lambda

aws upload object to S3 bucket and pass details of data to lambda

流过昼夜 提交于 2019-12-24 19:28:36
问题 Working my way through tutorials for AWS...So ive created an S3 bucket which when a file is dropped into it calls my lambda 'testHelloWorld' which sends an email...this all works fine (see below) 'use strict'; console.log('Loading function'); var aws = require('aws-sdk'); var ses = new aws.SES({ region: 'us-west-2' }); exports.handler = function(event, context) { console.log("Incoming: ", event); // var output = querystring.parse(event); var eParams = { Destination: { ToAddresses: ["johnb

How to pass headers from AWS API Gateway

我怕爱的太早我们不能终老 提交于 2019-12-24 19:15:26
问题 I'm passing the addition key-value pairs from lambda function, same as mention in aws labs. Then in API Gateway I have setup the body mapping templates in integration request. (Check this). But when request goes to the endpoint (PHP) then I'm unable to get any data. It is empty array print_r($_REQUEST); I checked cloudWatch this is what it is showing. Endpoint request body after transformations: { "userData" : "{"city":"USA","Name":"Sanket","id":3}" } Additional info - When I print print_r($

Can't enable CORS on Lambda + API Gateway + Cloudfront on the Cloudfront layer

强颜欢笑 提交于 2019-12-24 18:33:55
问题 I have deployed a lambda, which in itself returns an 'Access-Control-Allow-Origin': '*' header in it's response. I call it from an API Gateway. When calling the API gateway URL, the CORS configuration is fine. I placed CloudFront in front of the API, however now I am unable to access the API as the CORS configuration seems to be overridden by CloudFront, and I am not sure where to add custom headers in CloudFront. How do you enable CORS inside CloudFront? 回答1: Go into your CloudFront

Send data from cloud to aws iot thing

送分小仙女□ 提交于 2019-12-24 18:11:47
问题 I am trying to a reliable way to send data from aws lambda function to a aws iot thing. The thing is basically a raspberry pi which is located remotely. I have seen aws iot topics, but they don't seem to be reliable for my use case. So far I have found the following functionalities about topics Topics: Topics are asynchronous. When something is added to topic all and only currently listening devices will receive the update. There is no queueing. No delivery notification for the publisher. In

How can an aws lambda know what endpoint called it from API Gateway?

泪湿孤枕 提交于 2019-12-24 17:01:34
问题 If two different endpoints use one lambda, how can the lambda know about the parts of the URL path? How can one lambda know it was called from /zips vs /zip?zip_code=02140 ? I can use event["queryStringParameters"]['zip_Code'] to get the URLs query string - /zip?zip_code=02140 - from within the lambda, but how can I know if I am called from the /zips endpoint? I tried using event["pathStringParameters"]['zips'] which I created a test event for but that didn't work, not recognized. I can use

How to set Open/Download permissions on a file created in S3 with Amazon Lambda?

╄→гoц情女王★ 提交于 2019-12-24 16:03:06
问题 I have an Amazon Lambda function that successfully writes files to an Amazon S3 bucket. However, by default these files are not publicly accessible. How do I make them automatically accessible when they are written? Is there a way to change the bucket itself so that all items are publicly readable (open/download)? Alternatively, I've gleaned that this can be done with the IAM role policy. This is what I have: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs

SageMaker NodeJS's SDK is not locking the API Version

纵然是瞬间 提交于 2019-12-24 14:48:38
问题 I am running some code in AWS Lambda that dynamically creates SageMaker models. I am locking Sagemaker's API version like so: const sagemaker = new AWS.SageMaker({apiVersion: '2017-07-24'}); And here's the code to create the model: await sagemaker.createModel({ ExecutionRoleArn: 'xxxxxx', ModelName: sageMakerConfigId, Containers: [{ Image: ecrUrl }] }).promise() This code runs just fine locally with aws-sdk on 2.418.0 . However, when this code is deployed to Lambda, it doesn't work due to

AWS Lambda - events solely on root of S3 bucket

╄→гoц情女王★ 提交于 2019-12-24 14:15:45
问题 I'm writing an automated image resizing tool for S3 using Lambda. I'd like to create thumbnails in a subfolder of the bucket upon a PUT operation but if I put a file anywhere in the bucket the event is fired. Can some tell me how to make the event on fire on just actions in the root of the specified bucket but no in its subfolders? 回答1: It doesn't look like you can configure the S3 notification to fire only on certain paths, so the best option is to implement this logic in your Lambda

Mocking in AWS Lambda

女生的网名这么多〃 提交于 2019-12-24 13:06:50
问题 I have a simple AWS Node.js Lambda, which I would like to test using mocks: //SimpleLambda.js var AWS = require('aws-sdk'); exports.handler = function(event, context) { var name = getName(); context.succeed(name); }; function getName() { return 'David'; } I've installed mocha and simple-mock , but I am unable to get this to work: //test.js //Mocha var assert = require('assert'); //Chai var chai = require('chai'); var expect = chai.expect; var should = chai.should(); //Simple-Mock var simple =

How to map querystring and header to AWS C# lambda function parameter

笑着哭i 提交于 2019-12-24 12:53:00
问题 I have AWS Gateway REST API that takes 2 querystring parameters https://xxxxxx.xxxx.us-east-1.amazonaws.com/dev/pets?type=dog&page=1 The caller of the API also include x-api-key in the header. I want API gateway to pass querystring parameters and x-api-key to lambda function. So in AWS API Gateway Console i have configured the Integration Request as below The lambda function looks like this namespace AWSLambda1 { public class Function { public string FunctionHandler(LambdaRequest request,