Add MemoryReservation To ECS Container Definition

This commit is contained in:
Anshul Sharma 2016-08-24 12:02:53 +05:30
parent 70cc108614
commit c94cfd941d
2 changed files with 8 additions and 0 deletions

View File

@ -41,6 +41,10 @@ func dataSourceAwsEcsContainerDefinition() *schema.Resource {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"memoryReservation": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"disable_networking": &schema.Schema{ "disable_networking": &schema.Schema{
Type: schema.TypeBool, Type: schema.TypeBool,
Computed: true, Computed: true,
@ -65,6 +69,7 @@ func dataSourceAwsEcsContainerDefinitionRead(d *schema.ResourceData, meta interf
desc, err := conn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{ desc, err := conn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{
TaskDefinition: aws.String(d.Get("task_definition").(string)), TaskDefinition: aws.String(d.Get("task_definition").(string)),
}) })
if err != nil { if err != nil {
return err return err
} }
@ -83,6 +88,7 @@ func dataSourceAwsEcsContainerDefinitionRead(d *schema.ResourceData, meta interf
} }
d.Set("cpu", aws.Int64Value(def.Cpu)) d.Set("cpu", aws.Int64Value(def.Cpu))
d.Set("memory", aws.Int64Value(def.Memory)) d.Set("memory", aws.Int64Value(def.Memory))
d.Set("memoryReservation", aws.Int64Value(def.MemoryReservation))
d.Set("disable_networking", aws.BoolValue(def.DisableNetworking)) d.Set("disable_networking", aws.BoolValue(def.DisableNetworking))
d.Set("docker_labels", aws.StringValueMap(def.DockerLabels)) d.Set("docker_labels", aws.StringValueMap(def.DockerLabels))

View File

@ -17,6 +17,7 @@ func TestAccAWSEcsDataSource_ecsContainerDefinition(t *testing.T) {
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image", "mongo:latest"), resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image", "mongo:latest"),
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image_digest", "latest"), resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image_digest", "latest"),
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memory", "128"), resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memory", "128"),
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memoryReservation", "64"),
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "cpu", "128"), resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "cpu", "128"),
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "environment.SECRET", "KEY"), resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "environment.SECRET", "KEY"),
), ),
@ -43,6 +44,7 @@ resource "aws_ecs_task_definition" "mongo" {
"essential": true, "essential": true,
"image": "mongo:latest", "image": "mongo:latest",
"memory": 128, "memory": 128,
"memoryReservation": 64,
"name": "mongodb" "name": "mongodb"
} }
] ]