Home > Back-end >  getInstanceTypesFromInstanceRequirements always return 0 instance types
getInstanceTypesFromInstanceRequirements always return 0 instance types

Time:01-21

I am running the following API:

GetInstanceTypesFromInstanceRequirementsResult instanceRequirementsResult = this.amazonEC2Client
            .getInstanceTypesFromInstanceRequirements(new GetInstanceTypesFromInstanceRequirementsRequest()
                    .withInstanceRequirements(new InstanceRequirementsRequest().
                                                    withVCpuCount(new VCpuCountRangeRequest().withMin(0).withMax(100)).
                                                    withMemoryMiB(new MemoryMiBRequest().withMin(0).withMax(100))).
                                                    withArchitectureTypes(ArchitectureType.X86_64).
                                                    withVirtualizationTypes(VirtualizationType.Hvm).withMaxResults(100));

As per the docs, this is the minimum number of parameters that you need to pass. But this returns 0 instances. What did I miss?

CodePudding user response:

From docs:

MemoryMiB:

The minimum and maximum amount of memory, in MiB.

Type: MemoryMiBRequest object

Required: Yes

The parameter MemoryMiB is expressed in MB. So with a Max of 100MB, you are not obtaining results.

Try changing it to a higher value (e.g. 4096 = 4GB) or omitting the 'Max' field to set as unlimited:

Max

The maximum amount of memory, in MiB. To specify no maximum limit, omit this parameter.

Type: Integer

Required: No

  •  Tags:  
  • Related