Good day
Version 0.8.7
I try to create ECS service without Load Balancer. In terraform docs this step maked as Optional.
resource "aws_ecs_service" "elast-alert" {
name = "${module.elast_alert_naming.aws_ecs_service}"
cluster = "${aws_ecs_cluster.default.id}"
task_definition = "${aws_ecs_task_definition.elast-alert.arn}"
desired_count = "1"
iam_role = "${aws_iam_role.default.arn}"
deployment_maximum_percent = 100
deployment_minimum_healthy_percent = 0
}
Error applying plan:
1 error(s) occurred:
* aws_ecs_service.elast-alert: InvalidParameterException: A role was passed, but no load balancers were present.
status code: 400, request id: 53804203-f82d-11e6-816d-cd1a325f669e
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
In AWS I can create ECS service without ELB. Could I do the same with Terraform?
@Dgadavin I think if you remove the iam_role parameter from you resource this will be fixed. In the AWS documentation it states that when you define an iam_role you also have to define a load balancer.
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_paramters.html
role
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf. This parameter is required if you are using a load balancer with your service. If you specify the role parameter, you must also specify a load balancer object with the loadBalancers parameter.
Thanks. Will check it.
Thanks @MattiasGees. Your solution work fine.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
@Dgadavin I think if you remove the
iam_roleparameter from you resource this will be fixed. In the AWS documentation it states that when you define aniam_roleyou also have to define a load balancer.http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_paramters.html