无法创建图像ID不存在的aws实例?

时间:2013-11-30 08:56:25

标签: node.js amazon-web-services

我正在关注aws的tutorial on node.js来创建一个aws实例

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");
  });
}); 

它给了我一个错误说:

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 }

如何在aws控制台上找到有效的图像ID?

2 个答案:

答案 0 :(得分:1)

我没有看到你在任何地方指定你的区域,这可能解释了为什么找不到它 - 你没有告诉它在哪里看:

  

AWS.config.region =“us-east-1”; (例如)

答案 1 :(得分:0)

我认为你应该使用下面给出的默认am-ids指定区域:

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

检查this link for instance-types