diff --git a/builtin/providers/aws/resource_aws_ecs_service_test.go b/builtin/providers/aws/resource_aws_ecs_service_test.go index 53412ec028f8..2f9b8fedbf05 100644 --- a/builtin/providers/aws/resource_aws_ecs_service_test.go +++ b/builtin/providers/aws/resource_aws_ecs_service_test.go @@ -359,6 +359,8 @@ resource "aws_ecs_service" "ghost" { container_name = "ghost" container_port = "2368" } + + depends_on = ["aws_iam_role_policy.ecs_service"] } ` diff --git a/website/source/docs/providers/aws/r/ecs_service.html.markdown b/website/source/docs/providers/aws/r/ecs_service.html.markdown index 1a2d8fd9cb42..eb654b43f9a9 100644 --- a/website/source/docs/providers/aws/r/ecs_service.html.markdown +++ b/website/source/docs/providers/aws/r/ecs_service.html.markdown @@ -8,6 +8,8 @@ description: |- # aws\_ecs\_service +-> **Note:** To prevent race condition during service deletion, make sure to set `depends_on` to related `aws_iam_role_policy`, otherwise policy may be destroyed too soon and ECS service will then stuck in `DRAINING` state. + Provides an ECS service - effectively a task that is expected to run until an error occures or user terminates it (typically a webserver or a database). See [ECS Services section in AWS developer guide](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html). @@ -21,6 +23,7 @@ resource "aws_ecs_service" "mongo" { task_definition = "${aws_ecs_task_definition.mongo.arn}" desired_count = 3 iam_role = "${aws_iam_role.foo.arn}" + depends_on = ["aws_iam_role_policy.foo"] load_balancer { elb_name = "${aws_elb.foo.id}"