aws-lambda

“errorMessage”: “string argument without an encoding”, [duplicate]

强颜欢笑 提交于 2020-01-06 05:26:08
问题 This question already has answers here : TypeError: string argument without an encoding (3 answers) Closed yesterday . I'm trying to save password string encrypted in DynamoDb, I get this error. Response: { "errorMessage": "string argument without an encoding", "errorType": "TypeError", "stackTrace": [ " File \"/var/task/lambda_function.py\", line 25, in lambda_handler\n encrypted_password = encrypt(session, plain_text_password, key_alias)\n", " File \"/var/task/lambda_function.py\", line 11,

How to kick off AWS Glue Job when Crawler Completes

冷暖自知 提交于 2020-01-06 05:10:45
问题 I'm trying to figure out how to automatically kick off an AWS Glue Job when an AWS Glue Crawler completes. I see that the Crawlers send events when they complete, but I'm struggling to parse through the documentation to figure out how to listen to that event and then launch the AWS Glue Job. This seems like a fairly simple question, but I haven't been able to find any leads so far. I'd appreciate some help. Thanks in advance! 回答1: You can create a CloudWatch event, choose Glue Crawler state

Unable To Parse .csv in Python

雨燕双飞 提交于 2020-01-06 04:54:25
问题 I am doing a lab on the website LinuxAcademy.com. The Course name is Automating AWS with Lambda, Python, and Boto3 and the specific lab I am having trouble with is Lecture: Importing CSV Files into DynamoDB . In this lab we upload a .csv file into S3, an S3 event is generated in a specified bucket which then kicks off the Lambda function shown below. The function parses the .csv then uploads the contents into DynamoDB. I was originally having issues with Line 23: items = read_csv(download

Lambda Function not able to invoke sagemaker endpoint

本秂侑毒 提交于 2020-01-06 04:54:05
问题 predict = [0.1,0.2] payload = { "instances": [ { "features": predict } ] } response = linear_regressor.predict(json.dumps(payload)) predictions = json.loads(response) print(json.dumps(predictions, indent=2)) The above code is able to invoke the endpoint which is the linear-learner endpoint and give the below result. { "predictions": [ { "score": 0.13421717286109924 } ] } But when I try to invoke the endpoint using below lambda function, import json import io import boto3 client = boto3.client

Invoke a Lambda from a node package function

a 夏天 提交于 2020-01-06 03:21:10
问题 I have a Lambda function that imports a node package with common functions. Lambda 1 puts messages into SQS, Lambda 2 does error logging. One of the shared functions invokes Lambda 2, but there's an error on that second invocation. Lambda 1: exports.handler = function (event, context) { var pnmacCommon = require('./pnmacCommon.js'); //loading node package try { // this part omitted for space var aws = require('aws-sdk'); var sqs = new aws.SQS({ region : 'us-west-2' }); var params = {

How can I tell if my promise.all is running in parallel?

梦想与她 提交于 2020-01-06 02:49:08
问题 I have the following Promise.all example. I was wondering if it was operating in "parallel" in regards to the lambda.invoke ? And how can I test if something is running parallel? Referenced this thread function get1(id) { return new Promise((resolve, reject) => { const params = { FunctionName: 'myLambda', // the lambda function we are going to invoke InvocationType: 'RequestResponse', Payload: { id }, }; lambda.invoke(params, (err, data) => { if (err) { reject(new Error('error')); } else {

Run AWS Lambda code when creating a new AWS EC2 instance

为君一笑 提交于 2020-01-06 01:42:57
问题 I'd like to run some code using Lambda on the event that I create a new EC2 instance. Looking the blueprint config-rule-change-triggered I have the ability to run code depending on various configuration changes, but not when one is created. Is there a way to do what I want? Or have I misunderstood the use case of Lambda? 回答1: You could do this by inserting code into your EC2 instance launch userdata and have that code explicitly invoke a Lambda function, but that's not the best way to do it.

Prevent pip from installing some dependencies

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 13:12:59
问题 We're developing an AWS Lambda function for Alexa skill in Python and using pip to install the ask-sdk package to our dist/ directory: pip install -t dist/ ask-sdk The trouble is with the -t dist/ because pip wants to have all the dependencies there, even if they are installed system-wide. Now, ask-sdk has a dependency on boto3 which pulls in a whole lot of other packages. However the AWS Lambda runtime environment provides boto3 and there is no need to package that and its dependencies with

Prevent pip from installing some dependencies

送分小仙女□ 提交于 2020-01-05 13:11:44
问题 We're developing an AWS Lambda function for Alexa skill in Python and using pip to install the ask-sdk package to our dist/ directory: pip install -t dist/ ask-sdk The trouble is with the -t dist/ because pip wants to have all the dependencies there, even if they are installed system-wide. Now, ask-sdk has a dependency on boto3 which pulls in a whole lot of other packages. However the AWS Lambda runtime environment provides boto3 and there is no need to package that and its dependencies with

connecting to amazon rds with psycopg2 via lambda

点点圈 提交于 2020-01-05 09:26:33
问题 my code on aws lambda: import sys, boto3, logging, rds_config, psycopg2 rds_host = "hostname" name = rds_config.db_username password = rds_config.db_password db_name = rds_config.db_name s3 = boto3.resource('s3') rds_client = boto3.client('rds',aws_access_key_id=Access_Key,aws_secret_access_key=Secret_Access_Key) instances = rds_client.describe_db_instances() print (instances) try: conn = psycopg2.connect(host=rds_host, database=db_name, user=name, password=password) cur = conn.cursor()