boto

How to download the latest file of an S3 bucket using Boto3?

你离开我真会死。 提交于 2019-12-19 08:06:37
问题 The other questions I could find were refering to an older version of Boto. I would like to download the latest file of an S3 bucket. In the documentation I found that there is a method list_object_versions() that gets you a boolean IsLatest. Unfortunately I only managed to set up a connection and to download a file. Could you please show me how I can extend my code to get the latest file of the bucket? Thank you import boto3 conn = boto3.client('s3', region_name="eu-west-1", endpoint_url=

Dynamodb: query using more than two attributes

随声附和 提交于 2019-12-19 06:34:55
问题 In Dynamodb you need to specify in an index the attributes that can be used for making queries. How can I make a query using more than two attributes? Example using boto. Table.create('users', schema=[ HashKey('id') # defaults to STRING data_type ], throughput={ 'read': 5, 'write': 15, }, global_indexes=[ GlobalAllIndex('FirstnameTimeIndex', parts=[ HashKey('first_name'), RangeKey('creation_date', data_type=NUMBER), ], throughput={ 'read': 1, 'write': 1, }), GlobalAllIndex('LastnameTimeIndex'

Dynamodb: query using more than two attributes

人盡茶涼 提交于 2019-12-19 06:34:22
问题 In Dynamodb you need to specify in an index the attributes that can be used for making queries. How can I make a query using more than two attributes? Example using boto. Table.create('users', schema=[ HashKey('id') # defaults to STRING data_type ], throughput={ 'read': 5, 'write': 15, }, global_indexes=[ GlobalAllIndex('FirstnameTimeIndex', parts=[ HashKey('first_name'), RangeKey('creation_date', data_type=NUMBER), ], throughput={ 'read': 1, 'write': 1, }), GlobalAllIndex('LastnameTimeIndex'

Dynamodb: query using more than two attributes

﹥>﹥吖頭↗ 提交于 2019-12-19 06:33:17
问题 In Dynamodb you need to specify in an index the attributes that can be used for making queries. How can I make a query using more than two attributes? Example using boto. Table.create('users', schema=[ HashKey('id') # defaults to STRING data_type ], throughput={ 'read': 5, 'write': 15, }, global_indexes=[ GlobalAllIndex('FirstnameTimeIndex', parts=[ HashKey('first_name'), RangeKey('creation_date', data_type=NUMBER), ], throughput={ 'read': 1, 'write': 1, }), GlobalAllIndex('LastnameTimeIndex'

Querying for greatest value of Range key on AWS DynamoDb

半腔热情 提交于 2019-12-18 18:46:11
问题 What is the DynamoDB equivalent of SELECT MAX(RANGE_KEY) FROM MYTABLE WHERE PRIMARYKEY = "value" The best I can come up with is from boto.dynamodb2.table import Table as awsTable tb = awsTable("MYTABLE") rs = list(tb.query_2(PRIMARYKEY__eq="value", reverse=True, limit=1)) MAXVALUE = rs[0][RANGE_KEY] Is there a better way to do this? 回答1: That's the correct way. Because the records matched by the Hash Key are sorted by the Range Key, getting the first one by the descendant order will give you

Ansible ec2: “boto required for this module”

亡梦爱人 提交于 2019-12-18 14:52:21
问题 When I run this simple Ansible playbook: - name: EC2 Test Example hosts: localhost connection: local gather_facts: False tasks: - name: EC2 Instance ec2: # Amazon EC2 key pair name key_name: my-key-pair # Amazon EC2 Security Group group: my-security-group instance_type: t2.micro # Latest from https://wiki.debian.org/Cloud/AmazonEC2Image/Jessie image: ami-221ea342 wait: yes register: ec2 I run with venv/bin/ansible-playbook -i localhost, playbook.yml : PLAY [EC2 Test Example] *****************

Ansible ec2: “boto required for this module”

落爺英雄遲暮 提交于 2019-12-18 14:52:20
问题 When I run this simple Ansible playbook: - name: EC2 Test Example hosts: localhost connection: local gather_facts: False tasks: - name: EC2 Instance ec2: # Amazon EC2 key pair name key_name: my-key-pair # Amazon EC2 Security Group group: my-security-group instance_type: t2.micro # Latest from https://wiki.debian.org/Cloud/AmazonEC2Image/Jessie image: ami-221ea342 wait: yes register: ec2 I run with venv/bin/ansible-playbook -i localhost, playbook.yml : PLAY [EC2 Test Example] *****************

Obtaining tags from AWS instances with boto

ⅰ亾dé卋堺 提交于 2019-12-18 14:13:18
问题 I'm trying to obtain tags from instances in my AWS account using Python's boto library. While this snippet works correctly bringing all tags: tags = e.get_all_tags() for tag in tags: print tag.name, tag.value (e is an EC2 connection) When I request tags from individual instances, print vm.__dict__['tags'] or print vm.tags I'm getting an empty list (vm is actually an instance class). The following code: vm.__dict__['tags']['Name'] of course results in: KeyError: 'Name' My code was working

How to launch and configure an EMR cluster using boto

谁都会走 提交于 2019-12-18 11:27:39
问题 I'm trying to launch a cluster and run a job all using boto. I find lot's of examples of creating job_flows. But I can't for the life of me, find an example that shows: How to define the cluster to be used (by clusted_id) How to configure an launch a cluster (for example, If I want to use spot instances for some task nodes) Am I missing something? 回答1: Boto and the underlying EMR API is currently mixing the terms cluster and job flow , and job flow is being deprecated. I consider them

Disable boto logging without modifying the boto files

一曲冷凌霜 提交于 2019-12-18 10:44:41
问题 I am using the Boto library to talk to AWS. I want to disable logging. (Or redirect to /dev/null or other file). I cant find an obvious way to do this. I tried this, but that doesn't seem to help. import boto boto.set_file_logger('boto', 'logs/boto.log') This says it is possible, http://developer.amazonwebservices.com/connect/thread.jspa?messageID=52727&#52727 but AFAIK the documentation doesnt tell how. 回答1: You could try import logging logging.getLogger('boto').setLevel(logging.CRITICAL)