Search code examples
amazon-web-servicesamazon-ec2jclouds

JClouds creates default security group in AWS EC2, how can I block that?


I'm creating EC2 machines in AWS using JClouds. The machines are created without any issues but they are put into a default security group created by JClouds. A typical default security group by JClouds will have the "jclouds#" prefix like here:

jclouds#euweawlt-c96-j40788-26

Since we have predefined security groups I want to use them instead.

According the link JClouds AWS guide this should be possible through a simple line of code:

template.getOptions().as(EC2TemplateOptions.class).securityGroups(group1, group2);

So I've added it to my code as well:

computeTemplate.getOptions().as(EC2TemplateOptions.class).securityGroups(securityGroup);

...where securityGroup is the name of our predefined security group.

The same documentation page states that this should be enough:

"With respect to the security group, jclouds creates a security group for you, with rules corresponding to the inboundPorts() option (defaults to open port 22), unless you use the option EC2TemplateOptions.securityGroups()."

The end result is that the EC2 machine is added to the security group specified by the above code AND the default "jcloud#..." security group as well. Hence JClouds does create a default security group after all.

I really want to get rid of that since we already have a security group, it is not removed when the machine is terminated and there have been exceptions thrown by the JClouds API due the security group not being available after creation, whatever that means.

Any pointers are welcome.


Solution

  • Looking at the code, it looks like you're right and jclouds will always create that security group by default. I think there is no current workaround for that and I'd suggest you report that as an issue in the jclouds JIRA.

    I think the fix should be as easy as moving the highlighted lines into the previous else clause, but let's better open the issue so it can be properly tracked