I'm attempting to create instance on us-west-1c (though I get the same error when trying 1b, or any other AZ) and I'm getting this error:
Caught Exception: Status Code: 400, AWS Service: AmazonEC2, AWS Error Code: InvalidParameterValue, AWS Error Message: Invalid availability zone: [us-west-1c]
Response Status Code: 400
Error Code: InvalidParameterValue
I can manually create the instance via the AWS console. Here is my code to create that instance:
runInstancesRequest =
new RunInstancesRequest().withInstanceType("m1.medium")
.withImageId("ami-37b1b45e").withMinCount(1).withMaxCount(1)
.withSecurityGroupIds("launch-wizard-6")
.withKeyName("testkey");
Placement place = new Placement();
place.setAvailabilityZone("us-west-1c");
runInstancesRequest.setPlacement(place);
RunInstancesResult runInstancesResult = ec2.runInstances(runInstancesRequest);
I've looked over this a hundred times, compared to other examples I've found online but I'm unable to identify the reason for this error.
Any help would be very appreciated. Thanks!
Right-click the instance and select Create Image to make an AMI from the instance. Go to the AMI page, right-click on the new AMI and select Launch Instance. In the new instance settings, choose a specific (different) availability zone.
Similarly, if a failure in an Availability Zone causes an Amazon Aurora database to fail, a read-replica Aurora instance in an unaffected AZ can be automatically promoted to primary.
Each region in AWS is independent of the others, and the API endpoints are different.
It you aren't specifically configuring your code to send your request to the "us-west-1" region, then by default you're actually asking us-east-1 to create the instance in an availability zone that it's never heard of.
The AWS SDK for Java uses the US East (Northern Virginia) Region as the default region if you do not specify a region in your code.
— http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-region-selection.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With