java - Start ec2 instance with public ip -


i need start new instance in ec2 java code. can by:

    runinstancesrequest runinstancesrequest = new runinstancesrequest();  runinstancesrequest     .withimageid(myimageid)     .withinstancetype(myinstancetype)     .withmincount(instances_count)     .withmaxcount(instances_count)     .withkeyname(mykeyname)     .withsubnetid(mysubnetid)     .withsecuritygroupids(mysecuritygroupid)     .withplacement(myplace) ;  runinstancesresult runinstancesresult = amazonec2client.runinstances(runinstancesrequest); 

and creates new instance. instance has empty fields "public dns" , "public ip".

i not need elastic ip. ok if new instances have new addresses.

so, how change request it?

thanks! have found solution:

runinstancesrequest runinstancesrequest = new runinstancesrequest();  instancenetworkinterfacespecification interfacespecification = new instancenetworkinterfacespecification()     .withsubnetid(mysubnetid)     .withassociatepublicipaddress(true)     .withgroups(mysecuritygroupid)     .withdeviceindex(0);  runinstancesrequest     .withimageid(myimageid)     .withinstancetype(myinstancetype)     .withmincount(instances_count)     .withmaxcount(instances_count)     .withkeyname(mykeyname)     //.withsubnetid(mysubnetid)     //.withsecuritygroupids(mysecuritygroupid)     .withplacement(myplace)     .withnetworkinterfaces(interfacespecification) ;  runinstancesresult runinstancesresult = amazonec2client.runinstances(runinstancesrequest); 

i not know "deviceindex", , why "0", works.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -