@Override public IpPermission apply(SecurityGroupRule rule) { IpPermission.Builder builder = IpPermission.builder(); builder.ipProtocol(rule.getIpProtocol()); builder.fromPort(rule.getFromPort()); builder.toPort(rule.getToPort()); if (rule.getGroup() != null) { String region = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInRegion(rule.getGroup().getName())), null); if (region != null) { SecurityGroupInRegion group = groupMap.getUnchecked(RegionAndName.fromRegionAndName(region, rule.getGroup().getName())); builder.groupId(region + "/" + group.getSecurityGroup().getId()); } } if (rule.getIpRange() != null) builder.cidrBlock(rule.getIpRange()); return builder.build(); }
@Override public IpPermission apply(SecurityGroupRule rule) { IpPermission.Builder builder = IpPermission.builder(); builder.ipProtocol(rule.getIpProtocol()); builder.fromPort(rule.getFromPort()); builder.toPort(rule.getToPort()); if (rule.getGroup() != null) { String zone = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInZone(rule.getGroup().getName())), null); if (zone != null) { SecurityGroupInZone group = groupMap.getUnchecked(ZoneAndName.fromZoneAndName(zone, rule.getGroup().getName())); builder.groupId(zone + "/" + group.getSecurityGroup().getId()); } } if (rule.getIpRange() != null) builder.cidrBlock(rule.getIpRange()); return builder.build(); }