Bcf Ant
Bcf Ant

Reputation: 1749

Create EC2 instance with Boto3

I'm trying to create an instance using the following code.

import boto3
ec2 = boto3.resource('ec2', region_name='us-west-1')
ec2.create_instances(ImageId='ami-d0f506b0', MinCount=1, MaxCount=1)

I keep getting the following error;

An error occurred (InvalidAMIID.NotFound) when calling the RunInstances operation: The image id '[ami-d0f506b0]' does not exist

The AMI is the default Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type

I get the same error with my own AMI images and when I set the region name via ~/.aws/config

Any ideas why this is not working?

Upvotes: 1

Views: 821

Answers (1)

Shibashis
Shibashis

Reputation: 8401

Your REGION does not match the image id.

You need to use image "ami-6e84fa0e"

us-west-1 --> US West (N. California) : use image ami-6e84fa0e

us-west-2 --> US West (Oregon): use image ami-d0f506b0

Upvotes: 3

Related Questions