20482: Improves readability of instance profile assignment code.
[arvados.git] / tools / salt-install / terraform / aws / services / main.tf
index 48b6ef23cb6b5160831baafb5b20ce15b5b3c244..06b89dc779cecf34d683b3c217aa353ecd999f93 100644 (file)
@@ -58,9 +58,10 @@ resource "aws_instance" "arvados_service" {
   subnet_id = contains(local.user_facing_hosts, each.value) ? data.terraform_remote_state.vpc.outputs.public_subnet_id : data.terraform_remote_state.vpc.outputs.private_subnet_id
   vpc_security_group_ids = [ data.terraform_remote_state.vpc.outputs.arvados_sg_id ]
   # This should be done in a more readable way
-  iam_instance_profile = each.value == "controller" ? aws_iam_instance_profile.dispatcher_instance_profile.name : length(regexall("^keep[0-9]+", each.value)) > 0 ? aws_iam_instance_profile.keepstore_instance_profile.name : aws_iam_instance_profile.default_instance_profile.name
+  # iam_instance_profile = each.value == "controller" ? aws_iam_instance_profile.dispatcher_instance_profile.name : length(regexall("^keep[0-9]+", each.value)) > 0 ? aws_iam_instance_profile.keepstore_instance_profile.name : aws_iam_instance_profile.default_instance_profile.name
+  iam_instance_profile = try(local.instance_profile[each.value], local.instance_profile.default).name
   tags = {
-    Name = "arvados_service_${each.value}"
+    Name = "${local.cluster_name}_arvados_service_${each.value}"
   }
   root_block_device {
     volume_type = "gp3"