简体   繁体   中英

Cannot connect to EC2 using python boto

I'm a complete noob with Python and boto and trying to establish a basic connection to ec2 services. I'm running the following code:

ec2Conn = boto.connect_ec2('username','password')
group_name = 'python_central'
description = 'Python Central: Test Security Group.'
group = ec2Conn.create_security_group(group_name, description)
group.authorize('tcp', 8888,8888, '<a href="http://0.0.0.0/0">0.0.0.0/0</a>')

and getting the following error: AWS was not able to validate the provided access credentials

I've read some posts that this might be due to time difference between my machine and the EC2 server but according to the logs, they are the same:

host:ec2.us-east-1.amazonaws.com x-amz-date:20161213T192005Z

host;x-amz-date 515db222f793e7f96aa93818abf3891c7fd858f6b1b9596f20551dcddd5ca1be 2016-12-13 19:20:05,132 boto [DEBUG]:StringToSign:

Any idea how to get this connection running?

Thanks!

Call made to the AWS API require authentication via Access Key and Secret Key . These can be obtained from the Identity and Access Management (IAM) console, under the Security Credentials tab for a user.

See: Getting Your Access Key ID and Secret Access Key

If you are unfamiliar with Python, you might find it easier to call AWS services by using the AWS Command-Line Interface (CLI) . For example, this single-line command can launch an Amazon EC2 instance:

aws ec2 run-instances --image-id ami-c2d687ad --key-name joe --security-group-id sg-23cb34f6 --instance-type t1.micro

See: AWS CLI run-instances documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM