@@ -225,7 +225,7 @@ resource "aws_ecs_service" "this" {
225
225
for_each = try ([volume_configuration . value . managed_ebs_volume ], [])
226
226
227
227
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
229
229
encrypted = try (managed_ebs_volume. value . encrypted , null )
230
230
file_system_type = try (managed_ebs_volume. value . file_system_type , null )
231
231
iops = try (managed_ebs_volume. value . iops , null )
@@ -254,7 +254,8 @@ resource "aws_ecs_service" "this" {
254
254
255
255
depends_on = [
256
256
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 ,
258
259
]
259
260
260
261
lifecycle {
@@ -1505,8 +1506,9 @@ resource "aws_security_group_rule" "this" {
1505
1506
# ###########################################################################################
1506
1507
1507
1508
locals {
1508
- needs_infrastructure_iam_role = var. volume_configuration != null
1509
+ needs_infrastructure_iam_role = length ( var. volume_configuration ) > 0
1509
1510
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
1510
1512
infrastructure_iam_role_name = try (coalesce (var. infrastructure_iam_role_name , var. name ), " " )
1511
1513
}
1512
1514
0 commit comments