https://issues.apache.org/jira/browse/JCLOUDS-987

The changes required to make this work are basically:

* Call the logic to create the security groups also when the subnet id is set.
* Get the VPC id for the given subnet, as it is mandatory when creating 
security groups for instances that run in the VPC.
* Use the security group id instead of the name, as it is mandatory when 
creating them in an VPC.

The changes are pretty straightforward, but there is a subtle change: AWS-EC2 
and the generic EC2 providers have a cache `"region/group" -> String` where the 
resulting String is the security group name for that group. In AWS-EC2 now the 
resulting String is the security group ID instead of its name, allowing the 
creation of security groups in VPCs. The id form is always used to create 
security groups in AWS-EC2 (the generic EC2 provider remains unchanged as there 
is no VPC support there).

@abayer a quick review would be highly appreciated.
@richardcloudsoft Could you test if this change fixes the issue?
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds/pull/858

-- Commit Summary --

  * JCLOUDS-997: Create security groups in AWS if subnetId is specified

-- File Changes --

    M apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java (2)
    M 
apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java
 (10)
    M 
apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java
 (4)
    M 
apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java
 (12)
    M 
apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java
 (6)
    M 
apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java
 (30)
    M 
providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java
 (4)
    M 
providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java
 (21)
    M 
providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
 (26)
    M 
providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceApiMockTest.java
 (30)
    M 
providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionApiMockTest.java
 (2)
    M 
providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java
 (8)
    M 
providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java
 (70)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/858.patch
https://github.com/jclouds/jclouds/pull/858.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/858

Reply via email to