0

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!

4
  • 1
    You use boto to launch instances, not connect to instances. Do you want to ssh into the instance you created? Commented Dec 13, 2016 at 19:33
  • 2
    Where are you getting username and password from? The AWS API doesn't take a username/password, it takes an access key and secret key. You appear to be confusing AWS API access and EC2 SSH access. Commented Dec 13, 2016 at 19:34
  • @helloV I do try to launch instances. Sample code taken from here:pythoncentral.io/introduction-to-python-on-aws-with-boto Commented Dec 13, 2016 at 20:29
  • @MarkB You're correct, should be 'access key' and 'secret key'. Just looking to launch/shut down instances, no SSH connection involved Commented Dec 13, 2016 at 20:30

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.