func LoadSecurityGroupClass(name string, splitGrants bool) (SecurityGroupClass, error) {
	cfgs := make(SecurityGroupClasses)
	item, err := GetItemByName("securitygroups", name)
	if err != nil {
		return cfgs[name], err
	}
	cfgs.Marshal([]*simpledb.Item{item})
	cfg := cfgs[name]
	if splitGrants {
		var sGrants []SecurityGroupGrant
		for _, grant := range cfg.SecurityGroupGrants {
			for _, secGrp := range grant.SourceSecurityGroupNames {
				sGrant := grant
				sGrant.CidrIPs = []string{}
				sGrant.SourceSecurityGroupNames = []string{secGrp}
				sGrants = append(sGrants, sGrant)
			}
			for _, cidrIp := range grant.CidrIPs {
				sGrant := grant
				sGrant.SourceSecurityGroupNames = []string{}
				sGrant.CidrIPs = []string{cidrIp}
				sGrants = append(sGrants, sGrant)
			}
		}
		cfg.SecurityGroupGrants = sGrants
	}
	return cfg, nil
}
LoadSecurityGroupClass loads a Security Group Class by its name
package config
import (
	"encoding/json"
	"strconv"
	"strings"
	"github.com/aws/aws-sdk-go/service/simpledb"
)
type SecurityGroupClasses map[string]SecurityGroupClass
type SecurityGroupClass struct {
	Description         string               `json:"description" awsmClass:"Description"`
	SecurityGroupGrants []SecurityGroupGrant `json:"securityGroupGrants"  awsmClass:"Grants"`
}
type SecurityGroupGrant struct {
	ID                       string   `json:"id" hash:"ignore" awsm:"ignore"`
	Note                     string   `json:"note" hash:"ignore"`
	Type                     string   `json:"type"`  
	FromPort                 int      `json:"fromPort"`
	ToPort                   int      `json:"toPort"`
	IPProtocol               string   `json:"ipProtocol"`
	CidrIPs                  []string `json:"cidrIPs" hash:"set"`
	SourceSecurityGroupNames []string `json:"sourceSecurityGroupNames"`
}
func DefaultSecurityGroupClasses() SecurityGroupClasses {
	defaultSecurityGroups := make(SecurityGroupClasses)
	defaultSecurityGroups["dev"] = SecurityGroupClass{
		Description: "dev servers",
		SecurityGroupGrants: []SecurityGroupGrant{
			SecurityGroupGrant{
				Note:       "http port 80",
				Type:       "ingress",
				FromPort:   80,
				ToPort:     80,
				IPProtocol: "tcp",
				CidrIPs:    []string{"0.0.0.0/0"},
			},
			SecurityGroupGrant{
				Note:       "http port 443",
				Type:       "ingress",
				FromPort:   443,
				ToPort:     443,
				IPProtocol: "tcp",
				CidrIPs:    []string{"0.0.0.0/0"},
			},
		},
	}
	return defaultSecurityGroups
}
func SaveSecurityGroupClass(className string, data []byte) (class SecurityGroupClass, err error) {
	err = json.Unmarshal(data, &class)
	if err != nil {
		return
	}
	err = Insert("securitygroups", SecurityGroupClasses{className: class})
	return
}