aws-lambda

Cant get API Gateway `RequestId` in Lambda function

馋奶兔 提交于 2019-12-11 15:16:04
问题 I sent a post and get the response from amazon API Gateway as: {"MD5OfMessageBody": "bc709a65868c21309969a07cfeeac12f", "MD5OfMessageAttributes": "8a66ae91e9109cb75717520c287736eb", "MessageId": "b70a5453-5f30-4914-8006-b6cf7fa4ff93", "ResponseMetadata": {"RequestId": "1a38fbb5-859a-53f9-9551-a805d864768c", "HTTPStatusCode": 200, "HTTPHeaders": {"server": "Server", "date": "Fri, 29 Jun 2018 16:18:06 GMT", "content-type": "text/xml", "content-length": "459", "connection": "keep-alive", "x-amzn

How to Trigger Glue ETL Pyspark job through S3 Events or AWS Lambda?

前提是你 提交于 2019-12-11 15:07:36
问题 I'm planning to write certain jobs in AWS Glue ETL using Pyspark, which I want to get triggered as and when a new file is dropped in an AWS S3 Location, just like we do for triggering AWS Lambda Functions using S3 Events. But, I see very narrowed down options only, to trigger a Glue ETL script. Any help on this shall be highly appreciated. 回答1: The following should work to trigger a Glue job from AWS Lambda. Have the lambda configured to the appropriate S3 bucket, and IAM roles / permissions

AWS CloudFormation Template - How to configure Lambda with a SQS queue to pick the item from queue

笑着哭i 提交于 2019-12-11 14:59:58
问题 I am pretty new in AWS CloudFormaton template creation. Could not able to find the way to create a Lambda function which will connect with the SQS queue. Any example or resource would help me to learn and implement. 回答1: You need: AWS::SQS::Queue AWS::Lambda::Function AWS::Lambda::EventSourceMapping "DequeueInstanceQueue": { "Type": "AWS::SQS::Queue", "Properties": { "VisibilityTimeout": 301 }, "DeletionPolicy": "Delete" }, "DequeueInstanceMapping": { "Type": "AWS::Lambda::EventSourceMapping"

Choose primary index for Global secondary index

浪子不回头ぞ 提交于 2019-12-11 14:55:42
问题 I'm reading the AWS docs about secondary indices and I don't understand the following statement: The index key does not need to have any of the key attributes from the table From what I understand GSI allows me to create a primary or sort key on an attirubte in my table after its creation. I would like to make sure I understand the statement above, does it mean exactly that I can create a primary or sort key on an attribute that is different from the current table's primary/hash key? 回答1: Yes

Does AWS SAM CodePipelines do whole rebuild per commit?

做~自己de王妃 提交于 2019-12-11 14:48:27
问题 I am building a distributed app in AWS consisting of base resource (iam etc), data-warehousing but mostly serverless resources like lambdas, sns, mongodb,.. For deploying this over an OTAP I am looking into AWS tooling for this, mostly outlined here. This means that the 1 repo in CodeCommit will trigger the CodePipeline, which will have these components in de right places (realizing order control): deploying CF stacks using CodeBuild to package (AWS sam package) a SAM resource-> for every SAM

AWS Gateway always returns the default status code

空扰寡人 提交于 2019-12-11 14:31:57
问题 When I test my Lambda through AWS Gateway, I can see this lines being logged: Wed Jul 19 20:06:11 UTC 2017 : Method response body after transformations: {"errorCode":0,"headers":{},"statusCode":567,"base64Encoded":false} As you can see I'm returning 567 as status Code. But I always see 200: Then, this is my configuration in Integration Response: I'm using as reg exp .*"statusCode":567.* , but it is not matching with {"errorCode":0,"headers":{},"statusCode":567,"base64Encoded":false} . These

Invoke Lambda based on Kinesis records Partition Key

那年仲夏 提交于 2019-12-11 13:59:01
问题 I have different Types of data flowing in through my kinesis streams. Each of the record has a different partition key. I need to invoke a lambda function only if a record with certain partition key in added to the stream. Is there a way to specify that the lambda would be triggered only if a partition key "a" is encountered rather than invoking a lambda and then checking the partition key? 回答1: It's more kind of a Design Question, I don't know if you can configure this. But you can always

How can I post a PDF to AWS lambda

瘦欲@ 提交于 2019-12-11 13:26:57
问题 I have AWS Lambda set up. def lambda_handler(event, context): return { 'statusCode': 200, 'body': json.dumps(event) } I would like to POST in a PDF file so that I can operate on it in my lambda function. Here is my POST code import requests headers = { 'X-API-KEY':'1234', 'Content-type': 'multipart/form-data'} files = { 'document': open('my.pdf', 'rb') } r = requests.post(url, files=files, headers=headers) display(r) display(r.text) I am getting the error: <Response [400]> '{"message": "Could

AWS Lambda: Calling the Invoke API failed with message: [object Object]

泪湿孤枕 提交于 2019-12-11 13:15:31
问题 Today, all my Lambda function tests (in the AWS Lambda Console) have been yielding the following message: Calling the Invoke API failed with message: [object Object] Is anyone else experiencing this? It seems to work fine from the aws cli (and my context seems to be identical). 来源: https://stackoverflow.com/questions/52498213/aws-lambda-calling-the-invoke-api-failed-with-message-object-object

Can you clone an AWS lambda?

一曲冷凌霜 提交于 2019-12-11 12:55:02
问题 Cloning for different environments. Staging/QA/PROD/DEV etc. Is there a quick an easy way to clone my lambdas, give a different name, and adjust configurations from there? 回答1: This is an example of terraform code(Infrastructure as Code) which can be used to stamp out same lambdas within different environment dev/prod. If you have a look at this bit of code function_name = "${var.environment}-first_lambda" it will be clear as to how the name of the function is prefixed with environments like