user824624
user824624

Reputation: 8080

can't create aws instance that image id does not exist?

I am following the aws 's tutorial on node.js to create a aws instance

var ec2 = new AWS.EC2();

var params = {
  ImageId: "ami-2d4aa444",
  InstanceType: 't1.micro',
  MinCount: 1, MaxCount: 1
};

// Create the instance
ec2.runInstances(params, function(err, data) {
  if (err) { console.log("Could not create instance", err); return; }

  var instanceId = data.Instances[0].InstanceId;
  console.log("Created instance", instanceId);

  // Add tags to the instance
  params = {Resources: [instanceId], Tags: [
    {Key: 'Name', Value: instanceName}
  ]};
  ec2.createTags(params, function(err) {
    console.log("Tagging instance", err ? "failure" : "success");
  });
}); 

it gave me a error saying:

Could not create instance { [InvalidAMIID.NotFound: The image id '[ami-2d4aa444]
' does not exist]
  message: 'The image id \'[ami-2d4aa444]\' does not exist',
  code: 'InvalidAMIID.NotFound',
  name: 'InvalidAMIID.NotFound',
  statusCode: 400,
  retryable: false }

How can I find a valid a image id on the aws console ?

Upvotes: 0

Views: 3833

Answers (2)

sanster_23
sanster_23

Reputation: 860

I think you should use the default am-ids given below for your specified region:

ap-northeast-1  ami-50eaed51
ap-southeast-1  ami-f95875ab
eu-central-1    ami-ac1524b1
eu-west-1       ami-823686f5
sa-east-1       ami-c770c1da
us-east-1       ami-4ae27e22
us-west-1       ami-d1180894
cn-north-1      ami-fe7ae8c7
us-gov-west-1   ami-cf5630ec
ap-southeast-2  ami-890b62b3
us-west-2       ami-898dd9b9

Check this link for instance-types.

Upvotes: 2

E.J. Brennan
E.J. Brennan

Reputation: 46879

I don't see you specifying your region anywhere which would probably explain why it can't be found - you didn't tell it where to look:

AWS.config.region = "us-east-1"; (for example)

Upvotes: 1

Related Questions