1 package org.kuali.common.devops.aws;
2
3 import static com.google.common.collect.Lists.newArrayList;
4 import static org.kuali.common.aws.ec2.model.security.NamedPermissions.ALLOW_SSH_FROM_ANYWHERE;
5 import static org.kuali.common.aws.ec2.model.security.NamedPermissions.APPLICATION_SERVER_PERMISSIONS;
6
7 import java.util.List;
8
9 import org.kuali.common.aws.ec2.model.security.KualiSecurityGroup;
10 import org.kuali.common.aws.ec2.model.security.Permission;
11
12 import com.google.common.collect.ImmutableList;
13
14 public enum NamedSecurityGroups {
15
16
17
18 CI("ci", "Continuous Integration", ImmutableList.<Permission> of()),
19 CI_MASTER("ci.master", "Jenkins - Master", getMasterPermissions()),
20 CI_BUILD_SLAVE("ci.slave", "Jenkins - Slave", ALLOW_SSH_FROM_ANYWHERE.getPermission());
21
22 private final KualiSecurityGroup group;
23
24 private NamedSecurityGroups(String name, String description, Permission permission) {
25 this(name, description, ImmutableList.of(permission));
26 }
27
28 private NamedSecurityGroups(String name, String description, Permission... perms) {
29 this(name, description, ImmutableList.copyOf(perms));
30 }
31
32 private NamedSecurityGroups(String name, String description, List<Permission> perms) {
33 this.group = KualiSecurityGroup.builder(name).withDescription(description).withPermissions(perms).build();
34 }
35
36 public KualiSecurityGroup getGroup() {
37 return group;
38 }
39
40
41 private static final int JENKINS_MASTER_SSH_PORT = 45358;
42
43 private static List<Permission> getMasterPermissions() {
44 List<Permission> perms = newArrayList();
45 perms.addAll(APPLICATION_SERVER_PERMISSIONS);
46 perms.add(Permission.create(JENKINS_MASTER_SSH_PORT));
47 return ImmutableList.copyOf(perms);
48 }
49
50 }