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:
Since we have predefined security groups I want to use them instead.
According to the JClouds AWS guide (https://jclouds.apache.org/guides/aws-ec2/) this should be possible through a simple line of code:
So I've added it to my code as well:
...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.
I posted the same question on stack overflow here:
The answer by Ignasi Barrera suggests that a simple change in the source code should change this behaviour. Here's the link to the code that should be changed: