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); }
public SecurityGroupRuleException(SecurityGroupRule rule) : base($"SecurityGroup rule {rule.GetType().Name} ({rule.Peer}, {rule.Port}: {rule.Description}) is not expected") { }