Skip to content

Commit 06ec5e7

Browse files
committed
Changing variables default values in order to fix issue #1
1 parent dbaf284 commit 06ec5e7

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ Check the section "Other modules that you may need to use this module" for detai
3434
* region: AWS Region the infrastructure is hosted in.
3535
* ecs_cluster_arn: The ECS Cluster where the scheduled task will run.
3636
* event_rule_name: The rule's name.
37-
* ecs_execution_task_role_arn: The task definition execution role.
37+
* event_target_ecs_target_subnets: The subnets associated with the task or service.
38+
* event_target_ecs_target_task_definition_arn: The ARN of the task definition to use if the event target is an Amazon ECS cluster.
3839
* event_rule_schedule_expression: (Required, if event_pattern isn't specified) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes).
3940
* event_rule_event_pattern: (Required, if schedule_expression isn't specified) Event pattern described a JSON object. See full documentation of CloudWatch Events and Event Patterns for details.
40-
* event_target_ecs_target_task_definition_arn: The ARN of the task definition to use if the event target is an Amazon ECS cluster.
41-
* event_target_ecs_target_subnets: The subnets associated with the task or service.
4241
* event_rule_description: (Optional) The description of the rule.
4342
* event_rule_role_arn: (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
4443
* event_rule_is_enabled: (Optional) Whether the rule should be enabled (defaults to true).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Principal": {
7+
"Service": "ecs-tasks.amazonaws.com"
8+
},
9+
"Action": "sts:AssumeRole",
10+
"Sid": ""
11+
}
12+
]
13+
}

main.tf

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ provider "aws" {
66
region = var.region
77
}
88

9+
# ---------------------------------------------------------------------------------------------------------------------
10+
# AWS ECS Task Execution Role
11+
# ---------------------------------------------------------------------------------------------------------------------
12+
resource "aws_iam_role" "ecs_task_execution_role" {
13+
name = "${var.name_preffix}-ecs-task-execution-role"
14+
assume_role_policy = file("${path.module}/files/iam/ecs_task_execution_iam_role.json")
15+
}
16+
17+
resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy_attach" {
18+
role = aws_iam_role.ecs_task_execution_role.name
19+
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
20+
}
21+
922
# ---------------------------------------------------------------------------------------------------------------------
1023
# CLOUDWATCH EVENT ROLE
1124
# ---------------------------------------------------------------------------------------------------------------------
@@ -17,7 +30,7 @@ resource "aws_iam_role" "scheduled_task_cw_event_role" {
1730
data "template_file" "scheduled_task_cw_event_role_cloudwatch_policy" {
1831
template = "${file("${path.module}/files/iam/scheduled_task_cw_event_role_cloudwatch_policy.json")}"
1932
vars = {
20-
TASK_EXECUTION_ROLE_ARN = var.ecs_execution_task_role_arn
33+
TASK_EXECUTION_ROLE_ARN = aws_iam_role.ecs_task_execution_role.arn
2134
}
2235
}
2336

variables.tf

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ variable "event_rule_name" {
2323
description = "The rule's name."
2424
}
2525

26-
variable "event_rule_description" {
27-
description = "(Optional) The description of the rule."
28-
}
29-
3026
variable "event_rule_schedule_expression" {
3127
description = "(Required, if event_pattern isn't specified) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes)."
28+
default = null
3229
}
3330

3431
variable "event_rule_event_pattern" {
3532
description = "(Required, if schedule_expression isn't specified) Event pattern described a JSON object. See full documentation of CloudWatch Events and Event Patterns for details."
33+
default = null
34+
}
35+
36+
variable "event_rule_description" {
37+
description = "(Optional) The description of the rule."
38+
default = null
3639
}
3740

3841
variable "event_rule_role_arn" {
3942
description = "(Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation."
40-
default = ""
43+
default = null
4144
}
4245

4346
variable "event_rule_is_enabled" {
@@ -53,28 +56,28 @@ variable "ecs_cluster_arn" {
5356
description = "The ECS Cluster where the scheduled task will run"
5457
}
5558

59+
variable "event_target_ecs_target_subnets" {
60+
description = "The subnets associated with the task or service."
61+
type = list
62+
}
63+
64+
variable "event_target_ecs_target_task_definition_arn" {
65+
description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster."
66+
}
67+
5668
variable "event_target_target_id" {
5769
description = "(Optional) The unique target assignment ID. If missing, will generate a random, unique id."
58-
default = ""
70+
default = null
5971
}
6072

6173
variable "event_target_input" {
6274
description = "(Optional) Valid JSON text passed to the target."
63-
default = ""
75+
default = null
6476
}
6577

6678
variable "event_target_input_path" {
6779
description = "(Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target."
68-
default = ""
69-
}
70-
71-
variable "event_target_ecs_target_task_definition_arn" {
72-
description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster."
73-
}
74-
75-
variable "event_target_ecs_target_subnets" {
76-
description = "The subnets associated with the task or service."
77-
type = list
80+
default = null
7881
}
7982

8083
variable "event_target_ecs_target_security_groups" {
@@ -102,10 +105,5 @@ variable "event_target_ecs_target_platform_version" {
102105

103106
variable "event_target_ecs_target_group" {
104107
description = "(Optional) Specifies an ECS task group for the task. The maximum length is 255 characters."
105-
default = ""
108+
default = null
106109
}
107-
108-
variable "ecs_execution_task_role_arn" {
109-
description = "The task definition execution role"
110-
}
111-

0 commit comments

Comments
 (0)