简体   繁体   中英

Create AWS EC2 instance with specific flavour using jclouds and Java

I recently installed jclouds to use with eclipse to create a project in java to communicate with aws-ec2. Does anyone know if there is a way to create an instance using "instance flavours". I would appreciate it. Thank you very much.

There are a few ways to do this in jclouds. The easiest is just to use the hardwareId property when creating a node. This is a String whose value is the flavour of VM you wish to create, so m1.xlarge or m3.medium etc. Specify it as follows.

Template template = computeService.templateBuilder()
        .hardwareId(InstanceType.M1_MEDIUM);
nodes = computeService.createNodesInGroup("groupname", 1, template);

You can also just specify minumum RAM and CPU settings in the template, and let jclouds choose the hardware flavour itself, like this.

Template template = computeService.templateBuilder()
        .minCores(2.0d)
        .minRam(2048);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM