2016-06-15 19:55:45 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
2016-07-22 14:49:06 +02:00
|
|
|
func TestAccAWSEcsDataSource_ecsContainerDefinition(t *testing.T) {
|
2016-06-15 19:55:45 +02:00
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckAwsEcsContainerDefinitionDataSourceConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image", "mongo:latest"),
|
2016-08-04 21:26:43 +02:00
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image_digest", "latest"),
|
2016-06-15 19:55:45 +02:00
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memory", "128"),
|
2016-08-25 19:10:08 +02:00
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memory_reservation", "64"),
|
2016-06-15 19:55:45 +02:00
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "cpu", "128"),
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "environment.SECRET", "KEY"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const testAccCheckAwsEcsContainerDefinitionDataSourceConfig = `
|
|
|
|
resource "aws_ecs_cluster" "default" {
|
|
|
|
name = "terraformecstest1"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_ecs_task_definition" "mongo" {
|
|
|
|
family = "mongodb"
|
|
|
|
container_definitions = <<DEFINITION
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"cpu": 128,
|
|
|
|
"environment": [{
|
|
|
|
"name": "SECRET",
|
|
|
|
"value": "KEY"
|
|
|
|
}],
|
|
|
|
"essential": true,
|
|
|
|
"image": "mongo:latest",
|
|
|
|
"memory": 128,
|
2016-08-24 08:32:53 +02:00
|
|
|
"memoryReservation": 64,
|
2016-06-15 19:55:45 +02:00
|
|
|
"name": "mongodb"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
DEFINITION
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_ecs_service" "mongo" {
|
|
|
|
name = "mongodb"
|
|
|
|
cluster = "${aws_ecs_cluster.default.id}"
|
|
|
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
|
|
|
desired_count = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
data "aws_ecs_container_definition" "mongo" {
|
|
|
|
task_definition = "${aws_ecs_task_definition.mongo.id}"
|
|
|
|
container_name = "mongodb"
|
|
|
|
}
|
|
|
|
`
|