简体   繁体   中英

How to specify an instance type creating an AWS EC2 instance with the RunInstancesRequest

I would like to specify an instance type, ie “c4.large”, creating an AWS EC2 instance. The information about new instance is in RunInstanceRequest. How to specify an instance type creating an instance?

To specify the instance type in a RunInstancesRequest , you can use either:

For example:

r = new RunInstancesRequest();
r.setInstanceType('t1.micro');
r.setMinCount(1);
r.setMonitoring(true);

Note that there are also withInstanceType variants of these methods which allow you to chain initializer methods , for example:

r = new RunInstancesRequest()
    .withInstanceType('t1.micro')
    .withMinCount(1)
    .withMonitoring(true);

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