2017-01-31 17:27:58 +01:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
2017-01-31 23:40:31 +01:00
|
|
|
"fmt"
|
2017-01-31 17:27:58 +01:00
|
|
|
"testing"
|
|
|
|
|
2017-02-01 06:46:18 +01:00
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
2017-01-31 17:27:58 +01: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 15:51:26 +01:00
|
|
|
{
|
2017-01-31 17:27:58 +01: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 23:40:31 +01:00
|
|
|
var testAccCheckAwsEcsClusterDataSourceConfig = fmt.Sprintf(`
|
2017-01-31 17:27:58 +01:00
|
|
|
resource "aws_ecs_cluster" "default" {
|
2017-01-31 23:40:31 +01: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 17:27:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
data "aws_ecs_cluster" "default" {
|
|
|
|
cluster_name = "${aws_ecs_cluster.default.name}"
|
|
|
|
}
|
2017-02-01 06:46:18 +01:00
|
|
|
`, acctest.RandInt())
|