0

I have been trying to start an already launched EC2 instance via python. I have configured AWS CLI from command prompt using the command below

aws configure
aws_access_key_id = MY_ACCESS_KEY
aws_secret_access_key = MY_SECRET_KEY
region=us-west-2b
output=Table

Now I used the following code from Spyder IDE of Anaconda

import boto3
instanceID = 'i-XXXXXXXXXXad'
ec2 = boto3.client('ec2', region_name='us-west-2b')
ec2.start_instances(InstanceIds=['i-XXXXXXXXXad'])

This gives the following error

EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-west-2b.amazonaws.com/"

I have been trying to debug the error for hours now, any kind of help will be useful. Also, I have a .pem as well as .ppk file created to start the instance via Putty, the .ppk file also has a paraphrase, do I need to do any kind of additional steps for this?

1 Answer 1

3
region=us-west-2b

is not a region, it is an availability zone. Try:

region=us-west-2

You can test by:

$ host ec2.us-west-2b.amazonaws.com
Host ec2.us-west-2b.amazonaws.com not found: 3(NXDOMAIN)

$ host ec2.us-west-2.amazonaws.com
ec2.us-west-2.amazonaws.com has address 54.240.251.131
Sign up to request clarification or add additional context in comments.

3 Comments

Tried the same, it still gives the same result. Anything else that might be causing the problem?
@ArindamBose I am 100% sure you configured the region incorrect. See my update. What is the error message you are getting?
Hey, thanks a lot, I found out I was passing different region in boto3.client(). Now it's sorted.

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.