@@ -16,14 +16,17 @@ package utils
16
16
// ECS Params Reader is used to parse the ecs-params.yml file and marshal the data into the ECSParams struct
17
17
18
18
import (
19
+ "io/ioutil"
20
+ "os"
21
+
19
22
"github.com/aws/aws-sdk-go/aws"
20
23
"github.com/aws/aws-sdk-go/service/ecs"
24
+ libYaml "github.com/docker/libcompose/yaml"
21
25
"github.com/pkg/errors"
22
26
"gopkg.in/yaml.v2"
23
- "io/ioutil"
24
- "os"
25
27
)
26
28
29
+ // ECSParams contains the information parsed from the ecs-params.yml file
27
30
type ECSParams struct {
28
31
Version string
29
32
TaskDefinition EcsTaskDef `yaml:"task_definition"`
@@ -36,15 +39,23 @@ type EcsTaskDef struct {
36
39
TaskRoleArn string `yaml:"task_role_arn"`
37
40
ContainerDefinitions ContainerDefs `yaml:"services"`
38
41
ExecutionRole string `yaml:"task_execution_role"`
39
- TaskSize TaskSize `yaml:"task_size"` // Needed to run FARGATE tasks
42
+ TaskSize TaskSize `yaml:"task_size"` // Needed to run FARGATE tasks
40
43
}
41
44
45
+ // ContainerDefs is a map of ContainerDefs within a task definition
42
46
type ContainerDefs map [string ]ContainerDef
43
47
48
+ // ContainerDef specifies settings for a specific container
44
49
type ContainerDef struct {
45
50
Essential bool `yaml:"essential"`
51
+ // resource field yaml names correspond to equivalent docker-compose field
52
+ Cpu int64 `yaml:"cpu_shares"`
53
+ Memory libYaml.MemStringorInt `yaml:"mem_limit"`
54
+ MemoryReservation libYaml.MemStringorInt `yaml:"mem_reservation"`
46
55
}
47
56
57
+ // TaskSize holds Cpu and Memory values needed for Fargate tasks
58
+ // https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html
48
59
type TaskSize struct {
49
60
Cpu string `yaml:"cpu_limit"`
50
61
Memory string `yaml:"mem_limit"`
@@ -55,10 +66,14 @@ type RunParams struct {
55
66
NetworkConfiguration NetworkConfiguration `yaml:"network_configuration"`
56
67
}
57
68
69
+ // NetworkConfiguration specifies the network config for the task definition.
70
+ // Supports values 'awsvpc' (required for Fargate), 'bridge', 'host' or 'none'
58
71
type NetworkConfiguration struct {
59
72
AwsVpcConfiguration AwsVpcConfiguration `yaml:"awsvpc_configuration"`
60
73
}
61
74
75
+ // AwsVpcConfiguration specifies the networking resources available to
76
+ // tasks running in 'awsvpc' networking mode
62
77
type AwsVpcConfiguration struct {
63
78
Subnets []string `yaml:"subnets"`
64
79
SecurityGroups []string `yaml:"security_groups"`
0 commit comments