func newECSScheduler(db *empire.DB, c *Context) (*ecs.Scheduler, error) { logDriver := c.String(FlagECSLogDriver) logOpts := c.StringSlice(FlagECSLogOpts) logConfiguration := ecsutil.NewLogConfiguration(logDriver, logOpts) config := ecs.Config{ AWS: c, Cluster: c.String(FlagECSCluster), ServiceRole: c.String(FlagECSServiceRole), InternalSecurityGroupID: c.String(FlagELBSGPrivate), ExternalSecurityGroupID: c.String(FlagELBSGPublic), InternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPrivate), ExternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPublic), ZoneID: c.String(FlagRoute53InternalZoneID), LogConfiguration: logConfiguration, } s, err := ecs.NewLoadBalancedScheduler(db.DB.DB(), config) if err != nil { return nil, err } log.Println("Using ECS backend with the following configuration:") log.Println(fmt.Sprintf(" Cluster: %v", config.Cluster)) log.Println(fmt.Sprintf(" ServiceRole: %v", config.ServiceRole)) log.Println(fmt.Sprintf(" InternalSecurityGroupID: %v", config.InternalSecurityGroupID)) log.Println(fmt.Sprintf(" ExternalSecurityGroupID: %v", config.ExternalSecurityGroupID)) log.Println(fmt.Sprintf(" InternalSubnetIDs: %v", config.InternalSubnetIDs)) log.Println(fmt.Sprintf(" ExternalSubnetIDs: %v", config.ExternalSubnetIDs)) log.Println(fmt.Sprintf(" ZoneID: %v", config.ZoneID)) log.Println(fmt.Sprintf(" LogConfiguration: %v", logConfiguration)) return s, nil }
func newCloudFormationScheduler(db *empire.DB, c *cli.Context) (*cloudformation.Scheduler, error) { logDriver := c.String(FlagECSLogDriver) logOpts := c.StringSlice(FlagECSLogOpts) logConfiguration := ecsutil.NewLogConfiguration(logDriver, logOpts) config := newConfigProvider(c) zoneID := c.String(FlagRoute53InternalZoneID) zone, err := cloudformation.HostedZone(config, zoneID) if err != nil { return nil, err } t := &cloudformation.EmpireTemplate{ Cluster: c.String(FlagECSCluster), InternalSecurityGroupID: c.String(FlagELBSGPrivate), ExternalSecurityGroupID: c.String(FlagELBSGPublic), InternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPrivate), ExternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPublic), HostedZone: zone, ServiceRole: c.String(FlagECSServiceRole), CustomResourcesTopic: c.String(FlagCustomResourcesTopic), LogConfiguration: logConfiguration, ExtraOutputs: map[string]troposphere.Output{ "EmpireVersion": troposphere.Output{Value: empire.Version}, }, } if err := t.Validate(); err != nil { return nil, fmt.Errorf("error validating CloudFormation template: %v", err) } var tags []*cf.Tag if env := c.String(FlagEnvironment); env != "" { tags = append(tags, &cf.Tag{Key: aws.String("environment"), Value: aws.String(env)}) } s := cloudformation.NewScheduler(db.DB.DB(), config) s.Cluster = c.String(FlagECSCluster) s.Template = t s.StackNameTemplate = prefixedStackName(c.String(FlagEnvironment)) s.Bucket = c.String(FlagS3TemplateBucket) s.Tags = tags log.Println("Using CloudFormation backend with the following configuration:") log.Println(fmt.Sprintf(" Cluster: %v", s.Cluster)) log.Println(fmt.Sprintf(" InternalSecurityGroupID: %v", t.InternalSecurityGroupID)) log.Println(fmt.Sprintf(" ExternalSecurityGroupID: %v", t.ExternalSecurityGroupID)) log.Println(fmt.Sprintf(" InternalSubnetIDs: %v", t.InternalSubnetIDs)) log.Println(fmt.Sprintf(" ExternalSubnetIDs: %v", t.ExternalSubnetIDs)) log.Println(fmt.Sprintf(" ZoneID: %v", zoneID)) log.Println(fmt.Sprintf(" LogConfiguration: %v", t.LogConfiguration)) return s, nil }
func newECSScheduler(c *cli.Context) (scheduler.Scheduler, error) { logDriver := c.String(FlagECSLogDriver) logOpts := c.StringSlice(FlagECSLogOpts) logConfiguration := ecsutil.NewLogConfiguration(logDriver, logOpts) config := ecs.Config{ AWS: newConfigProvider(c), Cluster: c.String(FlagECSCluster), ServiceRole: c.String(FlagECSServiceRole), InternalSecurityGroupID: c.String(FlagELBSGPrivate), ExternalSecurityGroupID: c.String(FlagELBSGPublic), InternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPrivate), ExternalSubnetIDs: c.StringSlice(FlagEC2SubnetsPublic), ZoneID: c.String(FlagRoute53InternalZoneID), LogConfiguration: logConfiguration, } s, err := ecs.NewLoadBalancedScheduler(config) if err != nil { return nil, err } r, err := newDockerRunner(c) if err != nil { return nil, err } log.Println("Using ECS backend with the following configuration:") log.Println(fmt.Sprintf(" Cluster: %v", config.Cluster)) log.Println(fmt.Sprintf(" ServiceRole: %v", config.ServiceRole)) log.Println(fmt.Sprintf(" InternalSecurityGroupID: %v", config.InternalSecurityGroupID)) log.Println(fmt.Sprintf(" ExternalSecurityGroupID: %v", config.ExternalSecurityGroupID)) log.Println(fmt.Sprintf(" InternalSubnetIDs: %v", config.InternalSubnetIDs)) log.Println(fmt.Sprintf(" ExternalSubnetIDs: %v", config.ExternalSubnetIDs)) log.Println(fmt.Sprintf(" ZoneID: %v", config.ZoneID)) log.Println(fmt.Sprintf(" LogConfiguration: %v", logConfiguration)) return &scheduler.AttachedRunner{ Scheduler: s, Runner: r, }, nil }