Beispiel #1
0
// NewCustomResourceProvisioner returns a new CustomResourceProvisioner with an
// sqs client configured from config.
func NewCustomResourceProvisioner(db *sql.DB, config client.ConfigProvider) *CustomResourceProvisioner {
	p := &CustomResourceProvisioner{
		Provisioners: make(map[string]customresources.Provisioner),
		sendResponse: customresources.SendResponse,
		sqs:          sqs.New(config),
	}

	p.add("Custom::InstancePort", &InstancePortsProvisioner{
		ports: lb.NewDBPortAllocator(db),
	})

	p.add("Custom::ECSService", &ECSServiceResource{
		ecs: ecs.New(config),
	})

	store := &dbEnvironmentStore{db}
	p.add("Custom::ECSEnvironment", newECSEnvironmentProvisioner(&ECSEnvironmentResource{
		environmentStore: store,
	}))
	p.add("Custom::ECSTaskDefinition", newECSTaskDefinitionProvisioner(&ECSTaskDefinitionResource{
		ecs:              ecs.New(config),
		environmentStore: store,
	}))

	return p
}
Beispiel #2
0
// NewCustomResourceProvisioner returns a new CustomResourceProvisioner with an
// sqs client configured from config.
func NewCustomResourceProvisioner(empire *empire.Empire, config client.ConfigProvider) *CustomResourceProvisioner {
	db := empire.DB.DB.DB()
	p := &CustomResourceProvisioner{
		SQSDispatcher: newSQSDispatcher(config),
		Provisioners:  make(map[string]customresources.Provisioner),
		sendResponse:  customresources.SendResponse,
	}

	p.add("Custom::InstancePort", &InstancePortsProvisioner{
		ports: lb.NewDBPortAllocator(db),
	})

	ecs := newECSClient(config)
	p.add("Custom::ECSService", &ECSServiceResource{
		ecs: ecs,
	})

	store := &dbEnvironmentStore{db}
	p.add("Custom::ECSEnvironment", newECSEnvironmentProvisioner(&ECSEnvironmentResource{
		environmentStore: store,
	}))
	p.add("Custom::ECSTaskDefinition", newECSTaskDefinitionProvisioner(&ECSTaskDefinitionResource{
		ecs:              ecs,
		environmentStore: store,
	}))

	p.add("Custom::EmpireApp", &EmpireAppResource{
		empire: empire,
	})
	p.add("Custom::EmpireAppEnvironment", &EmpireAppEnvironmentResource{
		empire: empire,
	})

	return p
}
Beispiel #3
0
func newLBManager(db *sql.DB, config Config) (lbManager, error) {
	if err := validateLoadBalancedConfig(config); err != nil {
		return nil, err
	}

	// Create the ELB Manager
	elb := lb.NewELBManager(config.AWS)
	elb.Ports = lb.NewDBPortAllocator(db)
	elb.InternalSecurityGroupID = config.InternalSecurityGroupID
	elb.ExternalSecurityGroupID = config.ExternalSecurityGroupID
	elb.InternalSubnetIDs = config.InternalSubnetIDs
	elb.ExternalSubnetIDs = config.ExternalSubnetIDs

	// Compose the LB Manager
	var lbm lb.Manager = elb

	n := lb.NewRoute53Nameserver(config.AWS)
	n.ZoneID = config.ZoneID

	lbm = lb.WithLogging(lbm)

	return lb.WithCNAME(lbm, n), nil
}