InvalidAMIID.NotFound,AWS错误消息:AMI ID“AMI-c1aaabb5”不存在 [英] InvalidAMIID.NotFound, AWS Error Message: The AMI ID 'ami-c1aaabb5' does not exist
问题描述
我想推出的Ubuntu 12.04 LTS服务器64位,与EBS,编程。我已经写了下面的code:
I'm trying to launch a Ubuntu 12.04 LTS Server 64 bit, with EBS, programmatically. I've written the following code:
Placement placement = new Placement("eu-west-1b");
RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
.withPlacement(placement).withInstanceType("t1.micro")
.withImageId("ami-c1aaabb5").withMinCount(1).withMaxCount(1)
.withSecurityGroupIds("testGroup").withKeyName("testKey")
.withUserData(Base64.encodeBase64String(startupScript.getBytes()));
RunInstancesResult runInstances = amazonEC2.runInstances(runInstancesRequest);
List<Instance> instances = runInstances.getReservation().getInstances();
不过,我得到这个错误:
However, I get this error:
AWS错误code:InvalidAMIID.NotFound,AWS错误信息: AMI的IDAMI-c1aaabb5不存在
AWS Error Code: InvalidAMIID.NotFound, AWS Error Message: The AMI ID 'ami-c1aaabb5' does not exist
我发现,实例ID在亚马逊AWS控制台,也是在这个网址: http://cloud-images.ubuntu.com/releases/$p$pcise/release-20121001/
I've found that instance Id in Amazon AWS console and also at this URL: http://cloud-images.ubuntu.com/releases/precise/release-20121001/
我是什么做错了吗?
推荐答案
我已经想通了,默认情况下,请求被发送到美国弗吉尼亚州的数据中心,设置正确的端点解决了这个问题。
I've figured out, by default requests are sent to US Virginia data centre, setting the correct end point solved the problem.
public AmazonEC2 createAmazonEC2() {
AmazonEC2 ec2 = new AmazonEC2Client(createAwsCredentials());
ec2.setEndpoint("https://eu-west-1.ec2.amazonaws.com");
return ec2;
}
private AWSCredentials createAwsCredentials() {
AWSCredentials credentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
return credentials;
}
这篇关于InvalidAMIID.NotFound,AWS错误消息:AMI ID“AMI-c1aaabb5”不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!