boto3

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

Accessing a specific key in a s3 bucket using boto3

て烟熏妆下的殇ゞ 提交于 2020-01-06 04:41:18
问题 I am trying to access a specific object in my s3 bucket using boto3 for deletion. the code below is from the boto3 documentation. https://boto3.readthedocs.io/en/latest/guide/migrations3.html#accessing-a-bucket # Boto 3 for key in bucket.objects.all(): key.delete() great but i would much rather have a dictionary reference then iterating though objects. That isn't the greatest at scaling. Is there a way to grab an object using its key? edit: I attempted this but it didnt work. Looking through

Giving AWS Api Gateway Permission To Invoke Lambda Function using BOTO3

 ̄綄美尐妖づ 提交于 2020-01-05 05:36:10
问题 I am attempting to use BOTO3 to create an Api Gateway method that invokes a lambda function. I have so far been unable to find how to grant the necessary permissions. Curiously, setting the lambda method name manually through the AWS console sets up permissions automatically. I have been unable to replicate this in code. This is the code I am using to set up the gateway: # Create a rest api self.rest_api = self.apigateway.create_rest_api( name='AWS_CMS_Operations' ) # Get the rest api's root

In Boto3, how to create a Paginator for list_objects with additional keyword arguments?

时光怂恿深爱的人放手 提交于 2020-01-05 04:11:29
问题 I'm using a Paginator to iterate over the contents of an S3 bucket (following http://boto3.readthedocs.io/en/latest/guide/paginators.html#creating-paginators): client = boto3.client('s3') paginator = client.get_paginator('list_objects') page_iterator = paginator.paginate(Bucket=<my_bucket>) for page in page_iterator: for object in page['Contents']: key = object['Key'] In this example, the method name 'list_objects' is passed as a string. However, I would actually like to use a 'partial'

AWS RDS: how to get latest snapshot with boto3 and jmespath?

ⅰ亾dé卋堺 提交于 2020-01-05 02:33:06
问题 Here is what I tried: #!/usr/bin/env python3 import boto3 import jmespath from datetime import datetime, timedelta now = datetime.utcnow() yesterday = now - timedelta(days=1) boto3.setup_default_session(profile_name='profilename') rds_client = boto3.client('rds') response = rds_client.describe_db_snapshots(DBInstanceIdentifier='instanseid') snaplist=jmespath.search("DBSnapshots[?SnapshotCreateTime >`2016-10-24 06:11:30`].[DBSnapshotIdentifier]", response) print(snaplist) What I get is:

How to change storage class of existing key via boto3

偶尔善良 提交于 2020-01-04 03:59:16
问题 When using AWS S3 service, I need to change storage class of existing key from STANDARD to STANDARD_IA. change_storage_class from boto doesn't exist in boto3. What is the equivalent in Boto3? 回答1: from amazon doc You can also change the storage class of an object that is already stored in Amazon S3 by copying it to the same key name in the same bucket. To do that, you use the following request headers in a PUT Object copy request: x-amz-metadata-directive set to COPY x-amz-storage-class set

Problem creating Lambda function that has a Layer using boto3

自作多情 提交于 2020-01-04 03:50:26
问题 If I try to use boto3 Lambda create_function() to create a Lambda function, and I try to include Layers via Layers=['string'] parameter, I get the following error message: Unknown parameter in input: "Layers", must be one of: FunctionName, Runtime, Role, Handler, Code, Description, Timeout, MemorySize, Publish, VpcConfig, DeadLetterConfig, Environment, KMSKeyArn, TracingConfig, Tags ... any ideas? The documentation suggests that this should work, but something is clearly off here. NOTE: I

AWS Lambda Console - Upgrade boto3 version

南笙酒味 提交于 2020-01-03 17:49:31
问题 I am creating a DeepLens project to recognise people, when one of select group of people are scanned by the camera. The project uses a lambda, which processes the images and triggers the ' rekognition ' aws api. When I trigger the API from my local machine - I get a good response When I trigger the API from AWS console - I get failed response Problem After much digging, I found that the 'boto3' (AWS python library) is of version: 1.9.62 - on my local machine 1.8.9 - on AWS console Question

How to change aws-ec2 instance type?

余生颓废 提交于 2020-01-03 02:28:10
问题 I wanted to change the aws-ec2 instance type(e.g from micro to large or vice-versa etc) using Boto3. What are the factors that needs to be care while changing the instance type of ec2-instances. Here is my code: def get_ec2_boto3_connection(region, arn): sess = Boto3Connecton.get_boto3_session(arn) ec2_conn = sess.client(service_name='ec2', region_name=region) return ec2_conn def change_instance_type(arn,region): ec2_conn=get_ec2_boto3_connection(region,arn) ec2_conn.modify_instance_attribute

Getting Http Response from boto3 table.batch_writer object

こ雲淡風輕ζ 提交于 2020-01-01 16:59:08
问题 There is a list of data in a csv that I want to put into a dynamodb table on aws. See sample list below. Mary,F,7065 Anna,F,2604 Emma,F,2003 Elizabeth,F,1939 Minnie,F,1746 Margaret,F,1578 Ida,F,1472 Alice,F,1414 Bertha,F,1320 Sarah,F,1288 Annie,F,1258 Clara,F,1226 Ella,F,1156 Florence,F,1063 Cora,F,1045 Martha,F,1040 Laura,F,1012 Nellie,F,995 Grace,F,982 Carrie,F,949 Maude,F,858 Mabel,F,808 Bessie,F,796 Jennie,F,793 Gertrude,F,787 Julia,F,783 Hattie,F,769 Edith,F,768 Mattie,F,704 Rose,F,700