aws-lambda

Cloudfront Origin Group detect failver using Lambda@Edge

℡╲_俬逩灬. 提交于 2020-01-24 20:55:47
问题 My setup: I have a Cloudfront Origin Group where Bucket A is a primary bucket and Bucket B is a secondary bucket. Lambda@Edge is added on origin-request to do a certain process. Whenever a request comes to Cloudfront, my Lambda@Edge modifies it to match the folder structure of my bucket and returns file accordingly. If Bucket A doesn't have a certain file it throws an error and Cloudfront failover requests the file from Bucket B. Bucket B doesn't have the same structure as Bucket it, it

Lambda code works on node v8.10 but not nodejs v10.x

风流意气都作罢 提交于 2020-01-24 20:54:05
问题 I am working through a lambda course which was done using v8.10. I am trying to use nodejs v10.x since that is what I want to use for my project in the future. I am not understanding why the "const uuid = require('uuid');" line is throwing an import error only in nodejs v10 but in v8.10 the code runs just fine. Code: const aws = require('aws-sdk'); const s3 = new aws.S3(); const uuid = require('uuid'); exports.handler = async (event) => { console.log("Get the event to our S3POC class - " +

Google Sheets API works locally but timeout on connection when running from AWS Lambda

老子叫甜甜 提交于 2020-01-24 19:53:27
问题 I have some code that works perfectly locally and doesn't work at all from AWS Lambda. It's almost like the API is blocked and I'm not sure what to look for next. I can hit other things "out on the net" so it's not a generic routing issue and I get a socket timeout error from the AWS Run. I've tried a few different libraries including an older version of the main library. Everyone of them works locally, doesn't work from AWS. #!/usr/bin/env python3 # replace creds_file = "/path/to/creds.json"

Subscribe an Amazon SNS topic using AWS Lambda function?

痞子三分冷 提交于 2020-01-24 15:14:08
问题 Can we subscribe an Amazon SNS topic using an AWS Lambda function? 回答1: Yes. With help of sns.subscribe() Please keep in mind: dont forget to confirm it sns.confirmSubscription() 回答2: If you mean can you use a message from a SNS topic as the trigger for a lambda function, then the answer is yes. If you mean can you write a lambda function that adds a subscription to an SNS topic then the answer is yes. Towards the bottom are links for the language-specific AWS SDKs. Your Lambda function would

Subscribe an Amazon SNS topic using AWS Lambda function?

十年热恋 提交于 2020-01-24 15:13:16
问题 Can we subscribe an Amazon SNS topic using an AWS Lambda function? 回答1: Yes. With help of sns.subscribe() Please keep in mind: dont forget to confirm it sns.confirmSubscription() 回答2: If you mean can you use a message from a SNS topic as the trigger for a lambda function, then the answer is yes. If you mean can you write a lambda function that adds a subscription to an SNS topic then the answer is yes. Towards the bottom are links for the language-specific AWS SDKs. Your Lambda function would

How to Install ffmpeg on aws lambda machine?

天涯浪子 提交于 2020-01-24 14:38:27
问题 I'm trying to run a node js script on aws lambda that uses ffmpeg. To do this, I need to install ffmpeg on the machine itself. I have looked trhough the documentation but I could not find how to connect to the machine that runs the lambda. 回答1: You don't ever connect to the "machine" the Lambda is running on. There is no single machine the function runs on, and the function isn't even deployed until the first time it is called. The Lambda runs in one or more containers that are created and

How do I grant a rotation Lambda access to AWS Secrets Manager

非 Y 不嫁゛ 提交于 2020-01-24 13:04:06
问题 Using the serverless framework, I am trying to build a Lambda function that periodically rotates a secret stored in AWS Secrets Manager. I am having trouble configuring the roles needed for the Secret Manager to execute the Lambda. In my serverless.yml I have defined the following resources: resources: Resources: RotateKeysRole: Type: AWS::IAM::Role Properties: RoleName: rotate-keys-role ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

Move a file from one folder to another folder in s3

我的梦境 提交于 2020-01-24 12:44:05
问题 First I'm trying to copy the file into other folder and unable to delete it. How I can delete the file only if the file is copied to the destination folder. const s3Params = { Bucket: bucket, CopySource: bucket + '/' + objectkey, Key: 'processed-data/' + objectkey }; function copyFile() { s3.copyObject(s3Params, function (err, data) { if (err) { console.log(err); } else { deleteFile(); } }); } function deleteFile() { s3.deleteObject(s3Params, function (err, data) { if (err) { console.log(err,

Cron Job fires twice in Serverless using AWS Lambda

大城市里の小女人 提交于 2020-01-24 12:33:53
问题 I am running a Cron Job which runs every Sunday at 10:00am UTC It pushes a Text Message to a Telegram Group Here's my full code Relevant parts below - serverless.yml service: lessons-of-hn-telegram-bot provider: name: aws runtime: nodejs8.10 environment: BOT_API_KEY: ${file(./env.json):BOT_API_KEY} CHANNEL_ID: ${file(./env.json):CHANNEL_ID} functions: cron: handler: handler.run description: Cron job that runs every Sunday at 10 am UTC events: - schedule: cron(0 10 ? * SUN *) handler.js const

Cron Job fires twice in Serverless using AWS Lambda

雨燕双飞 提交于 2020-01-24 12:33:13
问题 I am running a Cron Job which runs every Sunday at 10:00am UTC It pushes a Text Message to a Telegram Group Here's my full code Relevant parts below - serverless.yml service: lessons-of-hn-telegram-bot provider: name: aws runtime: nodejs8.10 environment: BOT_API_KEY: ${file(./env.json):BOT_API_KEY} CHANNEL_ID: ${file(./env.json):CHANNEL_ID} functions: cron: handler: handler.run description: Cron job that runs every Sunday at 10 am UTC events: - schedule: cron(0 10 ? * SUN *) handler.js const