0
votes

I am a beginner.

When attempting to launch an EC2 instance (c4.2xlarge) using the com.amazonaws.services.ec2.model.RunInstancesRequest amazon services.

I got the following error.

2016-05-23 13:13:19 ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver: 213 - AmazonServiceException occurred when processing request: [POST] /leaseabuse-crawler-manager/instances/start
Virtualization type 'hvm' is required for instances of type 'c4.2xlarge'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 9c35befc-15ba-4010-b0c6-bf38285369f1). Stacktrace follows:
com.amazonaws.AmazonServiceException: Virtualization type 'hvm' is required for instances of type 'c4.2xlarge'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 9c35befc-15ba-4010-b0c6-bf38285369f1)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1369)
        at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:913)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:631)
        at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:400)
        at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:362)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:311)
        at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:11093)
        at com.amazonaws.services.ec2.AmazonEC2Client.runInstances(AmazonEC2Client.java:10618)
        at com.leaseabuse.devops.AwsService.startInstances(AwsService.groovy:167)
        at com.leaseabuse.devops.InstancesController.start(InstancesController.groovy:34)
        at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
        at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
2016-05-23 13:13:19 DEBUG grails.app.filters.com.leaseabuse.devops.ApiKeyFilters: 128 - Security enabled

Below are the code I am trying to use

RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
                .withInstanceType(InstanceType.C42xlarge)
                .withImageId(amiId)
                .withMinCount(count)
                .withMaxCount(count)
                .withSecurityGroupIds("some-group")
                .withKeyName("Key-name")

Can anyone suggest me where I am going wrong. Please help to come out.

1

1 Answers

4
votes

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html

Linux Amazon Machine Images use one of two types of virtualization: paravirtual (PV) or hardware virtual machine (HVM). The main difference between PV and HVM AMIs is the way in which they boot and whether they can take advantage of special hardware extensions (CPU, network, and storage) for better performance.

For the best performance, we recommend that you use current generation instance types and HVM AMIs when you launch your instances.

The AMI ID you're using is a paravirtual one, and will thus only run on older generations of EC2 instances.