私はEC2インスタンスを操作するためにjcloudsを使い始めています。jcloudsで既存のsecurityGroupとpemファイルを使用する - Java
private ComputeService compute;
public void add(Integer instances) {
try {
logger.info("------------------------------------------------------");
logger.info(String.format(">> adding node to group %s%n", this.groupname));
// Default template chooses the smallest size on an operating system
// that tested to work with java, which tends to be Ubuntu or CentOS
TemplateBuilder templateBuilder = this.compute.templateBuilder();
// note this will create a user with the same name as you on the
// node. ex. you can connect via ssh publicip
Statement bootInstructions = AdminAccess.standard();
// to run commands as root, we use the runScript option in the template.
templateBuilder.options(runScript(bootInstructions));
Template template = templateBuilder.build();
// add a custom security group
NodeMetadata node = getOnlyElement(this.compute.createNodesInGroup(this.groupname, instances, template));
logger.info(String.format("<< node %s: %s%n", node.getId(),
concat(node.getPrivateAddresses(), node.getPublicAddresses())));
logger.info("------------------------------------------------------");
} catch (Exception e) {
logger.error(e.getMessage());
logger.info("------------------------------------------------------");
}
}
認証が正しいと仮定して groupname = default
てください:したがって、私は次のような方法があります。私は1つのインスタンスが作成されていても
this.compute.add(1);
を実行すると、jclouds
は新しいsecurity group
とkey pair
たびに作成されます。私は既存のfoo.pem
ファイルとdefault
セキュリティグループを持っています。たとえば、 security group = jclouds#default
です。既存のセキュリティグループとキーバリューをどのように活用できますか?