예제 #1
0
        public ISecurityGroup Create(string identification, string groupName, bool allowGroupAllOutbound, IVpc vpc, IPeer ingressPeer, Port ingressPort, IPeer egressPeer, Port egressPort)
        {
            var securityGroup = new SecurityGroup(Scope, identification, new SecurityGroupProps
            {
                AllowAllOutbound  = allowGroupAllOutbound,
                SecurityGroupName = groupName,
                Vpc = vpc
            });

            securityGroup.AddIngressRule(ingressPeer, ingressPort);
            securityGroup.AddEgressRule(egressPeer, egressPort);
            return(securityGroup);
        }
예제 #2
0
 public static SecurityGroup WithSecurityGroupRule(this SecurityGroup group, SecurityGroupRule rule)
 {
     if (rule is IngressRule)
     {
         group.AddIngressRule(rule.Peer, rule.Port, rule.Description, rule.RemoteRule);
     }
     else if (rule is EgressRule)
     {
         group.AddEgressRule(rule.Peer, rule.Port, rule.Description, rule.RemoteRule);
     }
     else
     {
         throw new SecurityGroupRuleException(rule);
     }
     return(group);
 }