Documentation
¶
Overview ¶
Package cloudformation implements the Scheduler interface for ECS by using CloudFormation to provision and update resources.
Index ¶
- Constants
- Variables
- func HostedZone(config client.ConfigProvider, hostedZoneID string) (*route53.HostedZone, error)
- type ContainerDefinitionProperties
- type CustomTaskDefinitionProperties
- type DockerClient
- type ECS
- type EmpireTemplate
- func (t *EmpireTemplate) Build(data *TemplateData) (*troposphere.Template, error)
- func (t *EmpireTemplate) ContainerDefinition(app *twelvefactor.Manifest, p *twelvefactor.Process) *ecs.ContainerDefinition
- func (t *EmpireTemplate) Execute(w io.Writer, data interface{}) error
- func (t *EmpireTemplate) Validate() error
- type PlacementConstraint
- type PortMappingProperties
- type Scheduler
- func (s *Scheduler) Remove(ctx context.Context, appID string) error
- func (s *Scheduler) Restart(ctx context.Context, appID string, ss twelvefactor.StatusStream) error
- func (m *Scheduler) Run(ctx context.Context, app *twelvefactor.Manifest) error
- func (s *Scheduler) Services(appID string) (map[string]string, error)
- func (s *Scheduler) Stop(ctx context.Context, taskID string) error
- func (s *Scheduler) Submit(ctx context.Context, app *twelvefactor.Manifest, ss twelvefactor.StatusStream) error
- func (s *Scheduler) SubmitWithOptions(ctx context.Context, app *twelvefactor.Manifest, ss twelvefactor.StatusStream, ...) error
- func (s *Scheduler) Tasks(ctx context.Context, app string) ([]*twelvefactor.Task, error)
- type SubmitOptions
- type TaskDefinitionProperties
- type Template
- type TemplateData
Constants ¶
const ( MaxDescribeTasks = 100 MaxDescribeServices = 10 MaxDescribeContainerInstances = 100 )
ECS limits
const (
MaxTemplateSize = 460800 // bytes
)
CloudFormation limits
See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
Variables ¶
var ( Ref = troposphere.Ref GetAtt = troposphere.GetAtt Equals = troposphere.Equals Join = troposphere.Join )
var DefaultStackNameTemplate = template.Must(template.New("stack_name").Parse("{{.Name}}"))
DefaultStackNameTemplate is the default text/template for generating a CloudFormation stack name for an app.
Functions ¶
func HostedZone ¶
func HostedZone(config client.ConfigProvider, hostedZoneID string) (*route53.HostedZone, error)
HostedZone returns the HostedZone for the ZoneID.
Types ¶
type ContainerDefinitionProperties ¶ added in v0.11.0
type ContainerDefinitionProperties struct { Command interface{} `json:",omitempty"` Cpu interface{} `json:",omitempty"` DockerLabels map[string]interface{} `json:",omitempty"` Environment interface{} `json:",omitempty"` Essential interface{} `json:",omitempty"` Image interface{} `json:",omitempty"` Memory interface{} `json:",omitempty"` Name interface{} `json:",omitempty"` PortMappings []*PortMappingProperties `json:",omitempty"` Ulimits interface{} `json:",omitempty"` LogConfiguration interface{} `json:",omitempty"` }
type CustomTaskDefinitionProperties ¶ added in v0.11.0
type CustomTaskDefinitionProperties struct { PlacementConstraints []*PlacementConstraint `json:",omitempty"` ContainerDefinitions []*ContainerDefinitionProperties `json:",omitempty"` Family interface{} `json:",omitempty"` ServiceToken interface{} `json:",omitempty"` Volumes []interface{} TaskRoleArn interface{} `json:",omitempty"` }
type DockerClient ¶ added in v0.13.0
type DockerClient interface { ListContainers(docker.ListContainersOptions) ([]docker.APIContainers, error) AttachToContainer(docker.AttachToContainerOptions) error }
DockerClient defines the interface we use when using Docker to connect to a running ECS task.
type ECS ¶ added in v0.13.0
ECS augments the ecs.ECS client with extra waiters.
func (*ECS) WaitUntilTasksNotPending ¶ added in v0.13.0
func (c *ECS) WaitUntilTasksNotPending(input *ecs.DescribeTasksInput) error
WaitUntilTasksNotPending waits until all the given tasks are either RUNNING or STOPPED.
type EmpireTemplate ¶
type EmpireTemplate struct { // By default, the JSON will not have any whitespace or newlines, which // helps prevent templates from going over the maximum size limit. If // you care about readability, you can set this to true. NoCompress bool // The ECS cluster to run the services in. Cluster string // The VPC to create ALB target groups within. Should be the same VPC // that ECS services will run within. VpcId string // The hosted zone to add CNAME's to. HostedZone *route53.HostedZone // The ID of the security group to assign to internal load balancers. InternalSecurityGroupID string // The ID of the security group to assign to external load balancers. ExternalSecurityGroupID string // The Subnet IDs to assign when creating internal load balancers. InternalSubnetIDs []string // The Subnet IDs to assign when creating external load balancers. ExternalSubnetIDs []string // The name or ARN of the IAM role to allow ECS, CloudWatch Events, and Lambda // to assume. ServiceRole string // The ARN of the SNS topic to provision instance ports. CustomResourcesTopic string LogConfiguration *ecs.LogConfiguration // Any extra outputs to attach to the template. ExtraOutputs map[string]troposphere.Output }
This implements the Template interface to create a suitable CloudFormation template for an Empire app.
func (*EmpireTemplate) Build ¶
func (t *EmpireTemplate) Build(data *TemplateData) (*troposphere.Template, error)
Build builds a Go representation of a CloudFormation template for the app.
func (*EmpireTemplate) ContainerDefinition ¶
func (t *EmpireTemplate) ContainerDefinition(app *twelvefactor.Manifest, p *twelvefactor.Process) *ecs.ContainerDefinition
ContainerDefinition generates an ECS ContainerDefinition for a process.
func (*EmpireTemplate) Execute ¶
func (t *EmpireTemplate) Execute(w io.Writer, data interface{}) error
Execute builds the template, and writes it to w.
func (*EmpireTemplate) Validate ¶
func (t *EmpireTemplate) Validate() error
Validate checks that all of the expected values are provided.
type PlacementConstraint ¶ added in v0.13.0
type PlacementConstraint struct { Type interface{} `json:",omitempty"` Expression interface{} `json:",omitempty"` }
type PortMappingProperties ¶ added in v0.11.0
type PortMappingProperties struct { ContainerPort interface{} `json:",omitempty"` HostPort interface{} `json:",omitempty"` }
type Scheduler ¶
type Scheduler struct { // Template is a text/template that will be executed using the // twelvefactor.Manifest as data. This template should return a valid // CloudFormation JSON template. Template Template // The ECS cluster to run tasks in. Cluster string // The name of the bucket to store templates in. Bucket string // A text/template that will generate the stack name for the app. This // template will be executed with a scheduler.App as it's data. StackNameTemplate *template.Template // Any additional tags to add to stacks. Tags []*cloudformation.Tag // NewDockerClient is used to open a new Docker connection to an ec2 // instance. NewDockerClient func(*ec2.Instance) (DockerClient, error) // contains filtered or unexported fields }
Scheduler implements the scheduler.Scheduler interface using CloudFormation to provision resources.
func NewScheduler ¶
func NewScheduler(db *sql.DB, config client.ConfigProvider) *Scheduler
NewScheduler returns a new Scheduler instance.
func (*Scheduler) Restart ¶ added in v0.11.0
func (s *Scheduler) Restart(ctx context.Context, appID string, ss twelvefactor.StatusStream) error
func (*Scheduler) Services ¶
Services returns a map that maps the name of the process (e.g. web) to the ARN of the associated ECS service.
func (*Scheduler) Submit ¶
func (s *Scheduler) Submit(ctx context.Context, app *twelvefactor.Manifest, ss twelvefactor.StatusStream) error
Submit creates (or updates) the CloudFormation stack for the app.
func (*Scheduler) SubmitWithOptions ¶
func (s *Scheduler) SubmitWithOptions(ctx context.Context, app *twelvefactor.Manifest, ss twelvefactor.StatusStream, opts SubmitOptions) error
SubmitWithOptions submits (or updates) the CloudFormation stack for the app.
type SubmitOptions ¶
type SubmitOptions struct { // When true, does not make any changes to DNS. This is only used when // migrating to this scheduler NoDNS *bool }
SubmitOptions are options provided to SubmitWithOptions.
type TaskDefinitionProperties ¶ added in v0.11.0
type TaskDefinitionProperties struct { PlacementConstraints []*PlacementConstraint `json:",omitempty"` ContainerDefinitions []*ContainerDefinitionProperties `json:",omitempty"` Volumes []interface{} TaskRoleArn interface{} `json:",omitempty"` }
type Template ¶
Template represents something that can generate a stack body. Conveniently the same interface as text/template.Template.
type TemplateData ¶ added in v0.12.0
type TemplateData struct { *twelvefactor.Manifest StackTags []*cloudformation.Tag }
Data handed to template generators.