@@ -225,7 +225,7 @@ resource "aws_ecs_service" "this" {
225225 for_each = try ([volume_configuration . value . managed_ebs_volume ], [])
226226
227227 content {
228- role_arn = try (aws_iam_role . infrastructure_iam_role [ 0 ] . arn , var . infrastructure_iam_role_arn )
228+ role_arn = local . infrastructure_iam_role_arn
229229 encrypted = try (managed_ebs_volume. value . encrypted , null )
230230 file_system_type = try (managed_ebs_volume. value . file_system_type , null )
231231 iops = try (managed_ebs_volume. value . iops , null )
@@ -254,7 +254,8 @@ resource "aws_ecs_service" "this" {
254254
255255 depends_on = [
256256 aws_iam_role_policy_attachment . service ,
257- aws_iam_role_policy_attachment . infrastructure_iam_role_ebs_policy
257+ aws_iam_role_policy_attachment . infrastructure_iam_role_ebs_policy ,
258+ aws_iam_role . infrastructure_iam_role ,
258259 ]
259260
260261 lifecycle {
@@ -1505,8 +1506,9 @@ resource "aws_security_group_rule" "this" {
15051506# ###########################################################################################
15061507
15071508locals {
1508- needs_infrastructure_iam_role = var. volume_configuration != null
1509+ needs_infrastructure_iam_role = length ( var. volume_configuration ) > 0
15091510 create_infrastructure_iam_role = var. create && var. create_infrastructure_iam_role && local. needs_infrastructure_iam_role
1511+ infrastructure_iam_role_arn = local. needs_infrastructure_iam_role ? try (aws_iam_role. infrastructure_iam_role [0 ]. arn , var. infrastructure_iam_role_arn ) : null
15101512 infrastructure_iam_role_name = try (coalesce (var. infrastructure_iam_role_name , var. name ), " " )
15111513}
15121514
0 commit comments