aws-lambda

Unable to set a lambda's role from CDK

Unable to set a lambda's role from CDK Question: I have the following code: EventbridgeToLambda( self, "Some", lambda_function_props=lambda_.FunctionProps( code=lambda_.InlineCode(lambda_code), handler="index.lambda_handler", runtime=lambda_.Runtime.PYTHON_3_8, # Set timeout to something other than 3 seconds timeout=Duration.seconds(45), layers=[lambdaLayer], environment={ "S3_BUCKET": "dev_environment_bucket", }, role=iam.Role.from_role_arn( self, id="x", role_arn="arn:aws:iam::numbers:path/rolename", mutable=True ), vpc=ec2.Vpc.from_lookup(self, "VPC", vpc_id="vpc-0hex"), allow_public_subnet=True, vpc_subnets=ec2.SubnetSelection( subnets=[ec2.Subnet.from_subnet_id(self, "Subnet", "subnet-0hex")] ), security_groups=[ec2.SecurityGroup.from_lookup_by_id(self, "SG", "sg-0hex")], ), …

Total answers: 1

How to make inference from a model using Lambda?

How to make inference from a model using Lambda? Question: I trained an image segmentation model with Mask-RCNN and my goal now is to make inference using AWS Lambda, for this I am modifying the Deploy multiple machine learning models for inference on AWS Lambda and Amazon EFS, my project tree is: . ├── Dockerfile …

Total answers: 1

passing a csv through an API

passing a csv through an API Question: I’m trying to pass a csv through an api like this: The csv is as follow: field_1, field_2, field_3 1, 3, 7 the push code is this: with open("sample_csv.csv") as f: data = {"file": f} print(data) headers = { "Content-Type": "text/csv", "File-Type": "POS", "File-Key": "somekey", } r = …

Total answers: 2

Lambda function triggered when adding files to a S3 bucket

Lambda function triggered when adding files to a S3 bucket Question: I am having a problem with the behavior of a Lambda function. Ultimately, I want my lambda function to read some information about json files that I upload to my S3 bucket. Here is a test function: import boto3 import json s3=boto3.client(‘s3’) def LambdaHandler(event,context): …

Total answers: 2

Python Lambda Function returning KeyError

Python Lambda Function returning KeyError Question: Currently trying to create a (simple) Lambda function in AWS using Python 3.8: import json import urllib3 def lambda_handler(event, context): status_code = 200 array_of_rows_to_return = [ ] http = urllib3.PoolManager() try: event_body = event["body"] payload = json.loads(event_body) rows = payload["data"] for row in rows: row_number = row[0] from_currency = …

Total answers: 1

Saving a json/txt file to S3 from Lambda

Saving a json/txt file to S3 from Lambda Question: I am using lambda to run a program. Once it is run I need to save some data as a json file or txt. I tried to see if there is a way to write a file in lambda and save it but there are no …

Total answers: 1