Hi all,

I'm trying to create nodes in EC2 in a non-default VPC, setting only subnetId 
on TemplateOptions (no security groups). Like so:

  AWSEC2TemplateOptions templateOptions = new AWSEC2TemplateOptions();
  ... some more template options setup that shouldn't be relevant
  templateOptions.subnetId("subnet-mysubnet");
  Template template = templateBuilder.
                .hardwareId(instanceType)
                .locationId(region)
                .imageId(imageId)
                .options(templateOptions)
                .build();
  Iterables.getOnlyElement(computeService.createNodesInGroup("cloudts-rjanik", 
1, template));

I'm running into problems with that, however. I also tried setting a security 
group via TemplateOptions.securityGroupIds(), but it seems the issue persists. 
The stacktrace is here: http://pastebin.com/xKAEg9cu

I found out that JClouds always (even if using non-default VPC and even if 
security groups have been provided) attempts to create some kind of marker 
security group in

  
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.getSecurityGroupsForTagAndOptions

When the security group is created, it tries to resolve the name into ID by 
calling

  
Iterables.getOnlyElement(api.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region,
 name), null).getId();

That fails for security groups in non-default VPC, because to use the 
DescribeSecurityGroups action there, IDs have to be provided instead of names 
[1].

So, my question is, is this a bug or is there a way to work around this? We 
don't have an account with a default VPC and I found no way to manually create 
one, so that probably won't work. Any ideas?

Thanks for suggestions,
R.

[1]: 
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSecurityGroups.html

Reply via email to