aws-lambda

Serverless framework with python and aws lambda

Serverless framework with python and aws lambda Question: When i import a function from another file and do the deploy it doesn’t work. It gives me: error 500 internal server error. The python requirements works fine, because the hello function doesn’t give me an error. But getPrediction doesn’t work well In offline mode all works …

Total answers: 1

Exception handling in AWS – Explicitly ignore some errors?

Exception handling in AWS – Explicitly ignore some errors? Question: I have a Lambda function that’s used to verify the integrity of a file, but for simplicity sake, let’s just assume that it copies a file from a bucket into a bucket upon trigger (lambda gets triggered when it detects file ingestion). The problem that …

Total answers: 1

AWS Lambda new line using boto3

AWS Lambda new line using boto3 Question: This should be quite straightforward but I’m a bit stuck. I have a Lambda function in AWS that sends out daily email with FX rates, I’m just trying to add a new line in the body of the email that gets sent out using boto3 but ‘n’ doesn’t …

Total answers: 1

How to delete file(s) from source s3 bucket after lambda successfully copies file(s) to destination s3 bucket?

How to delete file(s) from source s3 bucket after lambda successfully copies file(s) to destination s3 bucket? Question: I have the following the lambda function which uses an s3 trigger to copy files from a source to a destination bucket. This is working fine. import os import logging import boto3 LOGGER = logging.getLogger() LOGGER.setLevel(logging.INFO) DST_BUCKET …

Total answers: 1

Unable to import module AWS Lambda Function

Unable to import module AWS Lambda Function Question: I’m having issues running basically any lambda function on AWS as the Lambda Function tool would not be able to import the module. I tried to import the packages as layers – pretty wrong I think. (https://www.linkedin.com/pulse/add-external-python-libraries-aws-lambda-using-layers-gabe-olokun/) Then I’ve tried to import the packages as environments (from …

Total answers: 2

Get filename from S3 bucket path

Get filename from S3 bucket path Question: I am getting the last modified file from S3 bucket using the below code: import boto3 import urllib.parse import json import botocore.session as bc import time from time import mktime from datetime import datetime print(‘Loading function’) def lambda_handler(event, context): s3_client = boto3.client("s3") list_of_s3_objs = s3_client.list_objects_v2(Bucket="mybucket", Prefix="folder/sub/") # Returns …

Total answers: 2

How to read text file on AWS Lambda environment

How to read text file on AWS Lambda environment Question: I am trying to read and store the values of a text file in a variable so that I can covert that text file into CSV file afterwards. But I am getting this error that the file is not found. I used the exact path …

Total answers: 1

How to upload excel file to AWS S3 using an AWS lambda function in python

How to upload excel file to AWS S3 using an AWS lambda function in python Question: I have an excel file in generated from a Lamba function, stored in the /tmp/ folder, I want to store it in a S3 bucket, I have setup the permisions and the bucket, but when I complete the function …

Total answers: 2

Reduce size of authorization python AWS Lambda@Edge

Reduce size of authorization python AWS Lambda@Edge Question: I’m trying to implement authorization in my cloudfront distribution. It has worked so far until I ran into size limitation. I’m now running into the cloudfront error message Max allowed: 1048576, which is roughly ~1MB. But after installing the authlib package the total size is around 6MB. …

Total answers: 1

boto3 : SSM Parameter get_parameters()

boto3 : SSM Parameter get_parameters() Question: I am creating lambda function where I am fetching SSM parameter for EKS-Optimized AMI ID, now about EKS-Optimized AMI, it is the default AMI provided by EKS if we are not specifying any AMI explicitly. EKS-Optimized AMI are different per region & K8 version. I am working on upgrading …

Total answers: 2