2017-01-31 10:27:58 -06:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
2017-01-31 16:40:31 -06:00
|
|
|
"fmt"
|
2017-01-31 10:27:58 -06:00
|
|
|
"testing"
|
|
|
|
|
2017-01-31 23:46:18 -06:00
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
2017-01-31 10:27:58 -06:00
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccAWSEcsDataSource_ecsCluster(t *testing.T) {
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
2017-02-01 08:51:26 -06:00
|
|
|
{
|
2017-01-31 10:27:58 -06:00
|
|
|
Config: testAccCheckAwsEcsClusterDataSourceConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_cluster.default", "status", "ACTIVE"),
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_cluster.default", "pending_tasks_count", "0"),
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_cluster.default", "running_tasks_count", "0"),
|
|
|
|
resource.TestCheckResourceAttr("data.aws_ecs_cluster.default", "registered_container_instances_count", "0"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-01-31 16:40:31 -06:00
|
|
|
var testAccCheckAwsEcsClusterDataSourceConfig = fmt.Sprintf(`
|
2017-01-31 10:27:58 -06:00
|
|
|
resource "aws_ecs_cluster" "default" {
|
2017-01-31 16:40:31 -06:00
|
|
|
name = "default-%d"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_ecs_task_definition" "mongo" {
|
|
|
|
family = "mongodb"
|
|
|
|
container_definitions = <<DEFINITION
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"cpu": 128,
|
|
|
|
"essential": true,
|
|
|
|
"image": "mongo:latest",
|
|
|
|
"memory": 128,
|
|
|
|
"memoryReservation": 64,
|
|
|
|
"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
|
2017-01-31 10:27:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
data "aws_ecs_cluster" "default" {
|
|
|
|
cluster_name = "${aws_ecs_cluster.default.name}"
|
|
|
|
}
|
2017-01-31 23:46:18 -06:00
|
|
|
`, acctest.RandInt())
|