From 574216f204b40e55dbc04f6b202e976c68006970 Mon Sep 17 00:00:00 2001 From: Kintaro-Oe Date: Thu, 5 Dec 2019 12:27:44 +0000 Subject: [PATCH] PLAT-2120 terraform 0.12 upgrade --- main.tf | 52 +++++++++++++++++++++++++--------------------------- outputs.tf | 13 +++++++------ variables.tf | 13 +++++++------ versions.tf | 4 ++++ 4 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 versions.tf diff --git a/main.tf b/main.tf index 77d6946..59ecc80 100644 --- a/main.tf +++ b/main.tf @@ -1,39 +1,34 @@ locals { - team = "${lookup(var.release, "team", "")}" - component = "${lookup(var.release, "component", "")}" - account_id = "${element(concat(data.aws_caller_identity.current.*.account_id, list("")), 0)}" + team = lookup(var.release, "team", "") + component = lookup(var.release, "component", "") + account_id = element( + concat(data.aws_caller_identity.current.*.account_id, [""]), + 0, + ) - name_prefix = "${ - length(var.family) <= 32 ? - var.family : - format("%.24stf%.4s", var.family, sha1(var.family)) - }" + name_prefix = length(var.family) <= 32 ? var.family : format("%.24stf%.4s", var.family, sha1(var.family)) } module "task_definition" { source = "github.com/mergermarket/tf_ecs_task_definition" - family = "${var.family}" - container_definitions = "${var.container_definitions}" - task_role_arn = "${aws_iam_role.task_role.arn}" - execution_role_arn = "${aws_iam_role.ecs_tasks_execution_role.arn}" - volume = "${var.volume}" + family = var.family + container_definitions = var.container_definitions + task_role_arn = aws_iam_role.task_role.arn + execution_role_arn = aws_iam_role.ecs_tasks_execution_role.arn + volume = var.volume } resource "aws_iam_role_policy" "role_policy" { - name_prefix = "${local.name_prefix}" - role = "${aws_iam_role.task_role.id}" - policy = "${var.policy}" + name_prefix = local.name_prefix + role = aws_iam_role.task_role.id + policy = var.policy } resource "aws_iam_role" "task_role" { - name_prefix = "${local.name_prefix}" + name_prefix = local.name_prefix description = "Task role for ${var.family}" - assume_role_policy = "${ - var.assume_role_policy == "" ? - data.aws_iam_policy_document.instance-assume-role-policy.json : - var.assume_role_policy - }" + assume_role_policy = var.assume_role_policy == "" ? data.aws_iam_policy_document.instance-assume-role-policy.json : var.assume_role_policy } data "aws_iam_policy_document" "instance-assume-role-policy" { @@ -48,19 +43,20 @@ data "aws_iam_policy_document" "instance-assume-role-policy" { } resource "aws_iam_role" "ecs_tasks_execution_role" { - name_prefix = "${local.name_prefix}" + name_prefix = local.name_prefix description = "Task execution role for ${var.family}" - assume_role_policy = "${data.aws_iam_policy_document.instance-assume-role-policy.json}" + assume_role_policy = data.aws_iam_policy_document.instance-assume-role-policy.json } data "aws_caller_identity" "current" { - count = "${var.is_test ? 0 : 1}" + count = var.is_test ? 0 : 1 } -data "aws_region" "current" {} +data "aws_region" "current" { +} resource "aws_iam_role_policy" "execution_role_policy" { - role = "${aws_iam_role.ecs_tasks_execution_role.id}" + role = aws_iam_role.ecs_tasks_execution_role.id name = "role_policy" policy = <