Skip to content

Commit 6d18cc6

Browse files
committed
(Chore) Terraform v0.12 updates
1 parent 3594cc8 commit 6d18cc6

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

main.tf

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,77 @@
22

33
resource "aws_iam_role" "scheduled_task_ecs_execution" {
44
name = "${var.name}-${var.environment}-st-ecs-execution-role"
5-
assume_role_policy = "${file("${path.module}/policies/scheduled-task-ecs-execution-assume-role-policy.json")}"
5+
assume_role_policy = file("${path.module}/policies/scheduled-task-ecs-execution-assume-role-policy.json")
66
}
77

88
data "template_file" "scheduled_task_ecs_execution_policy" {
9-
template = "${file("${path.module}/policies/scheduled-task-ecs-execution-policy.json")}"
9+
template = file("${path.module}/policies/scheduled-task-ecs-execution-policy.json")
1010
}
1111

1212
resource "aws_iam_role_policy" "scheduled_task_ecs_execution" {
1313
name = "${var.name}-${var.environment}-st-ecs-execution-policy"
14-
role = "${aws_iam_role.scheduled_task_ecs_execution.id}"
15-
policy = "${data.template_file.scheduled_task_ecs_execution_policy.rendered}"
14+
role = aws_iam_role.scheduled_task_ecs_execution.id
15+
policy = data.template_file.scheduled_task_ecs_execution_policy.rendered
1616
}
1717

1818
## ECS task role
1919

2020
resource "aws_iam_role" "scheduled_task_ecs" {
2121
name = "${var.name}-${var.environment}-st-ecs-role"
22-
assume_role_policy = "${file("${path.module}/policies/scheduled-task-ecs-assume-role-policy.json")}"
22+
assume_role_policy = file("${path.module}/policies/scheduled-task-ecs-assume-role-policy.json")
2323
}
2424

2525
## Cloudwatch event role
2626

2727
resource "aws_iam_role" "scheduled_task_cloudwatch" {
2828
name = "${var.name}-${var.environment}-st-cloudwatch-role"
29-
assume_role_policy = "${file("${path.module}/policies/scheduled-task-cloudwatch-assume-role-policy.json")}"
29+
assume_role_policy = file("${path.module}/policies/scheduled-task-cloudwatch-assume-role-policy.json")
3030
}
3131

3232
data "template_file" "scheduled_task_cloudwatch_policy" {
3333
template = "${file("${path.module}/policies/scheduled-task-cloudwatch-policy.json")}"
3434

3535
vars = {
36-
task_execution_role_arn = "${aws_iam_role.scheduled_task_ecs_execution.arn}"
36+
task_execution_role_arn = aws_iam_role.scheduled_task_ecs_execution.arn
3737
}
3838
}
3939

4040
resource "aws_iam_role_policy" "scheduled_task_cloudwatch_policy" {
4141
name = "${var.name}-${var.environment}-st-cloudwatch-policy"
42-
role = "${aws_iam_role.scheduled_task_cloudwatch.id}"
43-
policy = "${data.template_file.scheduled_task_cloudwatch_policy.rendered}"
42+
role = aws_iam_role.scheduled_task_cloudwatch.id
43+
policy = data.template_file.scheduled_task_cloudwatch_policy.rendered
4444
}
4545

4646
## ECS task definition
4747

4848
resource "aws_ecs_task_definition" "scheduled_task" {
4949
family = "${var.name}-${var.environment}-scheduled-task"
50-
container_definitions = "${var.container_definitions}"
50+
container_definitions = var.container_definitions
5151
requires_compatibilities = ["EC2"]
52-
network_mode = "${var.network_mode}"
53-
execution_role_arn = "${aws_iam_role.scheduled_task_ecs_execution.arn}"
54-
task_role_arn = "${aws_iam_role.scheduled_task_ecs.arn}"
55-
cpu = "${var.cpu}"
56-
memory = "${var.memory}"
52+
network_mode = var.network_mode
53+
execution_role_arn = aws_iam_role.scheduled_task_ecs_execution.arn
54+
task_role_arn = aws_iam_role.scheduled_task_ecs.arn
55+
cpu = var.cpu
56+
memory = var.memory
5757
}
5858

5959
## Cloudwatch event
6060

6161
resource "aws_cloudwatch_event_rule" "scheduled_task" {
6262
name = "${var.name}_${var.environment}_scheduled_task"
6363
description = "Run ${var.name}_${var.environment} task at a scheduled time (${var.schedule_expression})"
64-
schedule_expression = "${var.schedule_expression}"
64+
schedule_expression = var.schedule_expression
6565
}
6666

6767
resource "aws_cloudwatch_event_target" "scheduled_task" {
6868
target_id = "${var.name}_${var.environment}_scheduled_task_target"
69-
rule = "${aws_cloudwatch_event_rule.scheduled_task.name}"
70-
arn = "${var.cluster_arn}"
71-
role_arn = "${aws_iam_role.scheduled_task_cloudwatch.arn}"
69+
rule = aws_cloudwatch_event_rule.scheduled_task.name
70+
arn = var.cluster_arn
71+
role_arn = aws_iam_role.scheduled_task_cloudwatch.arn
7272
input = jsonencode({})
7373

7474
ecs_target {
75-
task_count = "${var.task_count}"
76-
task_definition_arn = "${aws_ecs_task_definition.scheduled_task.arn}"
75+
task_count = var.task_count
76+
task_definition_arn = aws_ecs_task_definition.scheduled_task.arn
7777
}
7878
}

variables.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
variable "name" {
2-
type = "string"
32
description = "Unique name for resources"
43
}
54

65
variable "environment" {
7-
type = "string"
86
description = "Environment - appended to var.name for resources"
97
}
108

119
variable "network_mode" {
12-
type = "string"
1310
description = "Task network mode"
1411
default = "bridge"
1512
}
1613

1714
variable "container_definitions" {
18-
type = "string"
1915
description = "Task container defintions"
2016
}
2117

2218
variable "schedule_expression" {
23-
type = "string"
2419
description = "Schedule expression (cron) for when to run task"
2520
}
2621

2722
variable "cluster_arn" {
28-
type = "string"
2923
description = "ARN of cluster on which to run task"
3024
}
3125

3226
variable "task_count" {
33-
type = "string"
3427
description = "Number of tasks to run"
3528
default = 1
3629
}
3730

3831
variable "cpu" {
39-
type = "string"
4032
description = "The number of cpu units used by the task"
4133
}
4234

4335
variable "memory" {
44-
type = "string"
4536
description = "The amount (in MiB) of memory used by the task"
4637
}

0 commit comments

Comments
 (0)