boto

Who created an Amazon EC2 instance using Boto and Python?

隐身守侯 提交于 2019-12-06 16:49:11
问题 I want to know who created a particular instance. I am using Cloud Trail to find out the statistics, but I am not able to get a particular statistics of who created that instance. I am using Python and Boto3 for finding out the details. I am using this code- Lookup events() from Cloud trail in boto3, to extract the information about an instance. ct_conn = sess.client(service_name='cloudtrail',region_name='us-east-1') events=ct_conn.lookup_events() 回答1: I found out the solution to the above

Can't get amazon cmd shell to work through boto

天大地大妈咪最大 提交于 2019-12-06 16:34:55
问题 I'm trying to create an instance and login to the server using ssh, I'm following an example from a book: import os import time import boto import boto.manage.cmdshell def launch_instance(ami="ami-54cf5c3d", instance_type="t1.micro", key_name="paws", key_extension=".pem", key_dir="~/.ssh", group_name="paws", ssh_port="22", cidr="0.0.0.0/0", tag="paws", user_data=None, cmd_shell=True, login_user="ec2-user", ssh_passwd=None): cmd=None ec2 = boto.connect_ec2() # Crededentials are stored in /etc

dynamodb row count via python, boto query

半城伤御伤魂 提交于 2019-12-06 16:01:23
问题 Folks, Am trying to get the following bit of code working to return the row count in a table: import boto import boto.dynamodb2 from boto.dynamodb2.table import Table from boto.dynamodb2.fields import HashKey, RangeKey drivers = Table('current_fhv_drivers') rowcountquery = drivers.query( number = 'blah', expiration = 'foo', count=True, ) for x in rowcountquery: print x['Count'] Error I see is: boto.dynamodb2.exceptions.UnknownFilterTypeError: Operator 'count' from 'count' is not recognized.

Bees with machine gun using Amazon free tier

社会主义新天地 提交于 2019-12-06 14:53:09
问题 I've been trying to use bees with machine gun without success. As far as I understand, this is just a fabric script that uses AWS to create EC2 instances (bees) in order to perform distributed load tests to a target (website). These are the steps I took: . Went to AWS IAM and created a new user and assigned to a group that has admin permissions: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "*", "Resource": "*" } ] } . The creation of this user gave me an aws_access

Boto: Dynamically get aws_access_key_id and aws_secret_access_key in Python code from config?

做~自己de王妃 提交于 2019-12-06 12:23:13
I have my aws_access_key_id and aws_secret_access_key stored in ~/.boto and was wondering if there was a way for me to retrieve these values in my python code using Boto as I need to insert them in to my SQL statement to to copy a CSV file from S3. This should work: import boto access_key = boto.config.get_value('Credentials', 'aws_access_key_id') secret_key = boto.config.get_value('Credentials', 'aws_secret_access_key') Here's a helper that will look in ~/.aws/credentials if boto.config doesn't work. I didn't look into it in great detail, but it kind of appears that Boto 2 doesn't look in ~/

How to access image by url on s3 using boto3?

早过忘川 提交于 2019-12-06 09:43:55
What I want to accomplish is to generate a link to view the file (ex.image or pdf). The item is not accessible by URL ( https://[bucket].s3.amazonaws.com/img_name.jpg ), I think because its private and not public? (I'm not the owner of the bucket, but he gave me the access_key and secret_key?) For now, all I can do is to download a file with this code. s3.Bucket('mybucket').download_file('upload/nocturnes.png', 'dropzone/static/pdf/download_nocturnes.png') I want to access an image on s3 so I can put it on an HTML, can I view it using the access and secret key?. Thank you for those who can

PermanentRedirect when calling the PutObject operation

谁说胖子不能爱 提交于 2019-12-06 09:25:38
The code below work locally and uploads files from a directory to S3. It's using Boto3 with Python 3. s3 = boto3.resource('s3', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_ACCESS_KEY_SECRET) bucket = s3.Bucket(bucket_name) uploadFileNames = [] for (sourceDir, dirname, filenames) in os.walk(sourceDir): for filename in filenames: bucket.put_object(Key=filename, Body=open("{}{}".format(sourceDir, filename), "rb")) break My problem is what when I run the same code on my production server (Ubuntu) I get the following error, why? return self._make_api_call(operation_name, kwargs)

Correct way to get output of run_pty from a boto sshclient

北城以北 提交于 2019-12-06 08:52:08
I am trying to execute a remote command on an ec2 instance that needs sudo. example code snippet conn = boto.ec2.connect_to_region(....) instance = conn.get_only_instances(instance_ids=instance_id)[0] ssh_client = sshclient_from_instance(instance, ssh_key_file='path.to.pem,user_name='ec2-user') chan = ssh_client.run_pty('sudo ls /root') Using just ssh_client.run() returns a tuple that was easy to deal with but doesn't allow sudo. run_pty is returning paramiko.channel.Channel and I can use recv() to get some output back but I am not clear how to get the entire stdout. 来源: https://stackoverflow

Can I get value of actual write capacity of DynamoDB or DynamoDB2 table

孤街浪徒 提交于 2019-12-06 06:48:41
问题 Suppose I access an existing DynamoDB import boto conn = boto.connect_dynamodb(...) table = conn.get_table(tableName) or a DynamoDB2 import boto from boto.dynamodb2.layer1 import DynamoDBConnection from boto.dynamodb2.table import Table conn = DynamoDBConnection(...) table = Table(tableName, connection=conn) table. I want to know how much data was written to it right before I accessed it. So I don't want the provisioned write throughput value but the actual throughput. How can I get this info

Error Handling: Boto: [Error 104] Connection Reset by Peer

一曲冷凌霜 提交于 2019-12-06 05:43:32
问题 I have a script that downloads from Amazon S3. The scripts works 99.9% of the time. Occasionally I get the following error (socket.error: [Errno 104] Connection reset by peer). Once I restart the code the error seems to go away. Since its hard to recreate the error. I'm hoping the snipped of code below will fix the error. Specifically, I'm hoping if the error comes up, it'll try to re-download the file. I'm wondering if this code will work, and if there is anything else I should add in. I'm