aws-lambda

How do I map AWS API Gateway query string to C# AWS Lambda function?

笑着哭i 提交于 2020-01-11 10:38:23
问题 I have a C# lambda function that is called from API gateway using a GET request. [LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] public ResponseModel MyFunction(RequestModel request) { return new ResponseModel { body = "Hello world!" }; } public class RequestModel { [JsonProperty("a")] public string A { get; set; } [JsonProperty("b")] public string B { get; set; } } public class ResponseModel { public int statusCode { get; set; } = 200; public object headers { get;

How to Rename or Copy Files on AWS Lambda function?

Deadly 提交于 2020-01-11 10:15:33
问题 I am a bit new to AWS / Lambda from the technical side so I have a scenario adn I wanted your help. I have a file that drops daily, I only care about the file on the last day of the month. They all drop to the same bucket the file drops at 8 EST. I then need to rename the file from the last day of the month to a static name, and copying it to a bucket lets say the file is called bill. I would want the previous file there called bill_september if we are in october. So my thought is to have a

Accessing Redshift from Lambda - Avoiding the 0.0.0.0/0 Security Group

*爱你&永不变心* 提交于 2020-01-11 09:48:20
问题 I am trying to access a Redshift database from a Lambda function. When I add 0.0.0.0/0 to the security group connections in the Redshift interface (as suggested by this article), I am able to connect successfully. From a security perspective, however, I don't feel comfortable using 0.0.0.0/0. Is there a way to only allow Lambda to access Redshift without opening it up to the public internet? I have tried adding the AWS IP ranges, however, this didn't work (as it only allows a limited number

Manually sign AppSync URL to use in Lambda gives bad signature error

一个人想着一个人 提交于 2020-01-10 20:17:29
问题 In a Lambda, I would like to sign my AppSync endpoint with aws-signature-v4 in order to use it for a mutation. The URL generated seems to be ok but it gives me the following error when I try it : { "errors" : [ { "errorType" : "InvalidSignatureException", "message" : "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. etc... } ] } Here is my lambda function import {

Manually sign AppSync URL to use in Lambda gives bad signature error

一世执手 提交于 2020-01-10 20:16:45
问题 In a Lambda, I would like to sign my AppSync endpoint with aws-signature-v4 in order to use it for a mutation. The URL generated seems to be ok but it gives me the following error when I try it : { "errors" : [ { "errorType" : "InvalidSignatureException", "message" : "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. etc... } ] } Here is my lambda function import {

Secure AWS API Gateway with Lambda Integration

谁说我不能喝 提交于 2020-01-10 15:40:49
问题 I am creating a publicly available API using API Gateway which is backed with lambda functions to do some processing. I have secured it with a custom security header that implements hmac authentication with timestamp to protect against replay attacks. I understand that API Gateway protects against DDOS attacks through its high availability, but any invalid requests will still be passed to the lambda authentication function. So, I guess an attacker can submit invalid unauthenticated requests

Can you publish a message to an SNS topic using an AWS Lambda function backed by node.js?

我只是一个虾纸丫 提交于 2020-01-09 04:14:17
问题 Can you publish a message to an SNS topic using an AWS Lambda function backed by node.js? 回答1: Yes, you could write a Lambda function that publishes to an SNS topic. The code running in Lambda has access to the full AWS SDK for Java or Javascript, whichever your function is using. You just need to make sure you give the IAM role executing the function access to publish to your topic. In Javascript: console.log("Loading function"); var AWS = require("aws-sdk"); exports.handler = function(event

If lambda can access the elasticsearch with in same vpc?

大兔子大兔子 提交于 2020-01-07 09:02:25
问题 within same VPC, If lambda can access the elasticsearch without applying IAM role? Is this possible? 回答1: You need to provide an IAM role for a lambda function and provide the IAM role access to ES. 回答2: If your Lambda runs within a VPC, you can configure the ElasticSearch access policy to an IP-based policy. AWS does provide samples for various kinds of access policies. IP based access policy 回答3: You will want to configure two Security Groups: Configure the Lambda function to use the VPC.

KeyError: 'awslogs' … outEvent = str(event['awslogs']['data']) - Python

南楼画角 提交于 2020-01-07 08:07:06
问题 I get the below error: Traceback (most recent call last): File "/var/task/lambda_function.py", line 22, in lambda_handler outEvent = str(event['awslogs']['data']) KeyError: 'awslogs' Code in use: import boto3 import logging import json import gzip import urllib import time from io import StringIO logger = logging.getLogger() logger.setLevel(logging.INFO) s3 = boto3.client('s3') def lambda_handler(event, context): #set the name of the S3 bucket bucketS3 = 'test-flowlogs' folderS3 = 'ArcSight'

Run Python3 without activating the virtual environment

萝らか妹 提交于 2020-01-07 04:58:14
问题 My objective is to run Python 3 code on the AWS Lambda Service, which currently only supports Python 2.7. These are the steps I have done. Since I work on a Mac, setup a docker image similar to the AWS Lambda Linux instance. Build Python3 from source on the docker image. In the docker image create a virtual environment and copy it to my project. AWS Lambda requires you to create a zip of the code and upload it to their service. For this prototype, I have a zip with three artifacts at the root