Yeah sure. This is my final code to create the security group:
AWSEC2SecurityGroupExtension client =
(AWSEC2SecurityGroupExtension)compute.getSecurityGroupExtension().get();
SecurityGroup sg = client.createSecurityGroup("crossbuild", CLOUD_REGION);
Builder b = IpPermission.builder();
b.fromPort(0);
b.toPort(65535);
b.groupId(sg.getProviderId());
b.ipProtocol(IpProtocol.TCP);
b.cidrBlock(CROSSBUILD_SECURITY_GROUP); //sth like 0.0.0.0/0
client.addIpPermission(b.build(), sg);
And now the catch, when setting the group name, the name is not actually
what you just wanted uit to be because Jclouds adds prefix "jclouds#" to
it. So when using security group in template builder, make sure you add
that prefix:
EC2TemplateOptions o = EC2TemplateOptions.Builder.
.overrideLoginCredentials(getLoginForCommandExecution(vmSettings)).securityGroups("jclouds#crossbuild");
On 16. 03. 2016 18:18, Andrew Phillips wrote:
>> After changing the group name in template to "jclouds#crossbuild" it
>> started working.
>
> Ah, glad to hear! Could you share your final code and perhaps a short
> description of "this is what I was trying to do, this approach didn't
> work, this different approach did"? I suspect that may turn into pretty
> useful reference material for others trying to do the same thing in
> future ;-)
>
> Regards
>
> ap