aws-lambda

How should I pass my s3 credentials to Python lambda function on AWS?

不羁的心 提交于 2020-12-08 11:04:58
问题 I'd like to write a file to S3 from my lambda function written in Python. But I’m struggling to pass my S3 ID and Key. The following works on my local machine after I set my local Python environment variables AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE to point to the local files I created with the AWS CLI. session = boto3.session.Session(region_name='us-east-2') s3 = session.client('s3', config=boto3.session.Config(signature_version='s3v4')) And the following works on Lambda where I hand

How should I pass my s3 credentials to Python lambda function on AWS?

感情迁移 提交于 2020-12-08 10:52:19
问题 I'd like to write a file to S3 from my lambda function written in Python. But I’m struggling to pass my S3 ID and Key. The following works on my local machine after I set my local Python environment variables AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE to point to the local files I created with the AWS CLI. session = boto3.session.Session(region_name='us-east-2') s3 = session.client('s3', config=boto3.session.Config(signature_version='s3v4')) And the following works on Lambda where I hand

How to make a role assumable by given lambda function?

心已入冬 提交于 2020-12-08 07:23:31
问题 We have this requirement came out of pen testing. I have a lambda function say "add_address" and a role "account_management_role". I want to make "account_management_role" assumable only by "add_address" lambda function. I do not want any other lambda function to assume this role. I tried different things, I tried adding this entry in "Trust Relationship" of IAM role. This did not work. Any one has any idea how to get this to work? { "Statement": [ { "Effect": "Allow", "Principal": { "Service

How to trigger a Lambda function at specific time in AWS?

删除回忆录丶 提交于 2020-12-08 06:08:08
问题 I am aware of the CloudWatch recurring events that can be used to run Lambda recurringly.. but is there a way that I can trigger it on a certain time and not repeat? 回答1: you can provide to it a cron expression or rate. what you are looking for is the cron expression option that will let you to say when exactly to run. more info - https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html if you want to run it once, manually, you can always trigger it

Scheduled AWS Lambda Task at less than 1 minute frequency

心已入冬 提交于 2020-12-08 05:36:10
问题 We are trying to develop a true lambda based application in which certain tasks need to be performed at schedules of variable frequencies. They are actually polling for data and at certain times of the day this polling can be as slow as once every hour while at other times it has to be once every second. I have looked at the options for scheduling (e.g. Using AWS Lambda with Scheduled Events and AWS re:Invent 2015 | (CMP407) Lambda as Cron: Scheduling Invocations in AWS Lambda) but it seems

Connecting Cassandra from AWS Lambda

旧时模样 提交于 2020-12-07 06:38:31
问题 We are checking the feasibility of migrating one of our application to Amazon Web Services (AWS) . We decide to use AWS API Gateway to expose the services and AWS Lambda (java) for back end data processing. The lambda function has to fetch a large amount of data from our database. Currently using Cassandra for data storage, which has been set up with in an EC2 instance and it has no public ip. Can anyone suggest a way to access Cassandra(EC2) from AWS Lambda using the private Ip ( 10.0.x.x)?

ValueError: non-string names in Numpy dtype unpickling only on AWS Lambda

半世苍凉 提交于 2020-12-07 04:48:29
问题 I am using pickle to save my trained ML model. For the learning part, I am using scikit-learn library and building a RandomForestClassifier rf = RandomForestClassifier(n_estimators=100, max_depth=20, min_samples_split=2, max_features='auto', oob_score=True, random_state=123456) rf.fit(X, y) fp = open('model.pckl', 'wb') pickle.dump(rf, fp, protocol=2) fp.close() I uploaded this model on S3 and I am fetching this model using boto3 library in AWS Lambda. s3_client = boto3.client('s3') bucket =

ValueError: non-string names in Numpy dtype unpickling only on AWS Lambda

丶灬走出姿态 提交于 2020-12-07 04:46:13
问题 I am using pickle to save my trained ML model. For the learning part, I am using scikit-learn library and building a RandomForestClassifier rf = RandomForestClassifier(n_estimators=100, max_depth=20, min_samples_split=2, max_features='auto', oob_score=True, random_state=123456) rf.fit(X, y) fp = open('model.pckl', 'wb') pickle.dump(rf, fp, protocol=2) fp.close() I uploaded this model on S3 and I am fetching this model using boto3 library in AWS Lambda. s3_client = boto3.client('s3') bucket =

AWS Lambda execute dynamic code

六月ゝ 毕业季﹏ 提交于 2020-12-05 12:41:58
问题 Is it possible to define a NodeJs function which evaluates dynamic nodejs code? Here is the context: The user creates custom javascript function which should return true / false. I need to "evaluate" the user code in a AWS Lambda container, which runs on NodeJs. Is it possible? Should i use something similar to javascript eval function? EDIT Here is what i tried 'use strict'; exports.handler = (event, context, callback) => { var body = "function test() { return 10; };"; console.log("body",

AWS Lambda execute dynamic code

╄→尐↘猪︶ㄣ 提交于 2020-12-05 12:41:27
问题 Is it possible to define a NodeJs function which evaluates dynamic nodejs code? Here is the context: The user creates custom javascript function which should return true / false. I need to "evaluate" the user code in a AWS Lambda container, which runs on NodeJs. Is it possible? Should i use something similar to javascript eval function? EDIT Here is what i tried 'use strict'; exports.handler = (event, context, callback) => { var body = "function test() { return 10; };"; console.log("body",