【问题标题】:can't create aws instance that image id does not exist?无法创建图像 ID 不存在的 aws 实例?
【发布时间】:2018-09-21 18:48:27
【问题描述】:

我正在关注 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?

【问题讨论】:

  • 每当您谈论 AMI 映像 ID 时,您也应该始终谈论一个区域 - 这些 ID 不是通用的,只能在特定区域的上下文中使用。在Ubuntu Cloud Images 中可以很好地看到它。

标签: node.js amazon-web-services


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    我认为您应该为您指定的区域使用下面给出的默认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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-05
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多