Skip to content

Commit 87dce82

Browse files
committed
Fixing pipeline
1 parent a84ce4c commit 87dce82

File tree

4 files changed

+61
-47
lines changed

4 files changed

+61
-47
lines changed

examples/test/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module "task" {
2626
source = "../../"
2727
name_prefix = "test-task"
2828
event_rule_name = "test-rule"
29+
event_rule_schedule_expression = "cron(0 20 * * ? *)"
2930
ecs_cluster_arn = module.cluster.aws_ecs_cluster_cluster_arn
3031
event_target_ecs_target_subnets = module.base-network.public_subnets_ids
3132
event_target_ecs_target_task_definition_arn = module.td.aws_ecs_task_definition_td_arn

main.tf

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ resource "aws_iam_role_policy" "scheduled_task_cw_event_role_cloudwatch_policy"
2424
#------------------------------------------------------------------------------
2525
resource "aws_cloudwatch_event_rule" "event_rule" {
2626
name = var.event_rule_name
27-
description = var.event_rule_description
2827
schedule_expression = var.event_rule_schedule_expression
28+
event_bus_name = var.event_rule_event_bus_name
2929
event_pattern = var.event_rule_event_pattern
30+
description = var.event_rule_description
3031
role_arn = var.event_rule_role_arn
3132
is_enabled = var.event_rule_is_enabled
3233
tags = {
@@ -38,18 +39,21 @@ resource "aws_cloudwatch_event_rule" "event_rule" {
3839
# CLOUDWATCH EVENT TARGET
3940
#------------------------------------------------------------------------------
4041
resource "aws_cloudwatch_event_target" "ecs_scheduled_task" {
41-
rule = aws_cloudwatch_event_rule.event_rule.name
42-
target_id = var.event_target_target_id
43-
arn = var.ecs_cluster_arn
44-
input = var.event_target_input
45-
input_path = var.event_target_input_path
46-
role_arn = aws_iam_role.scheduled_task_cw_event_role.arn
42+
rule = aws_cloudwatch_event_rule.event_rule.name
43+
event_bus_name = aws_cloudwatch_event_rule.event_rule.event_bus_name
44+
target_id = var.event_target_target_id
45+
arn = var.ecs_cluster_arn
46+
input = var.event_target_input
47+
input_path = var.event_target_input_path
48+
role_arn = aws_iam_role.scheduled_task_cw_event_role.arn
49+
4750
ecs_target {
48-
task_definition_arn = var.event_target_ecs_target_task_definition_arn
49-
task_count = var.event_target_ecs_target_task_count
50-
platform_version = var.event_target_ecs_target_platform_version
51-
launch_type = "FARGATE"
5251
group = var.event_target_ecs_target_group
52+
launch_type = "FARGATE"
53+
platform_version = var.event_target_ecs_target_platform_version
54+
task_count = var.event_target_ecs_target_task_count
55+
task_definition_arn = var.event_target_ecs_target_task_definition_arn
56+
5357
network_configuration {
5458
subnets = var.event_target_ecs_target_subnets
5559
security_groups = var.event_target_ecs_target_security_groups

outputs.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ output "aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_role"
5454
#------------------------------------------------------------------------------
5555
# CLOUDWATCH EVENT RULE
5656
#------------------------------------------------------------------------------
57+
output "aws_cloudwatch_event_rule_event_rule_id" {
58+
description = "The name of the rule."
59+
value = aws_cloudwatch_event_rule.event_rule.id
60+
}
61+
5762
output "aws_cloudwatch_event_rule_event_rule_arn" {
5863
description = "The Amazon Resource Name (ARN) of the CloudWatch Event Rule."
5964
value = aws_cloudwatch_event_rule.event_rule.arn
6065
}
61-

variables.tf

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ variable "name_prefix" {
99
# CLOUDWATCH EVENT RULE
1010
#------------------------------------------------------------------------------
1111
variable "event_rule_name" {
12-
description = "The rule's name."
12+
description = "The name of the rule."
1313
}
1414

1515
variable "event_rule_schedule_expression" {
16-
description = "(Required, if event_pattern isn't specified) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes)."
16+
description = "(Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event_rule_schedule_expression or event_rule_event_pattern is required. Can only be used on the default event bus."
17+
default = null
18+
}
19+
20+
variable "event_rule_event_bus_name" {
21+
description = "(Optional) The event bus to associate with this rule. If you omit this, the default event bus is used."
1722
default = null
1823
}
1924

2025
variable "event_rule_event_pattern" {
21-
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."
26+
description = "(Optional) The event pattern described a JSON object. At least one of schedule_expression or event_pattern is required."
2227
default = null
2328
}
2429

@@ -41,48 +46,37 @@ variable "event_rule_is_enabled" {
4146
#------------------------------------------------------------------------------
4247
# CLOUDWATCH EVENT TARGET
4348
#------------------------------------------------------------------------------
44-
variable "ecs_cluster_arn" {
45-
description = "The ECS Cluster where the scheduled task will run"
46-
}
47-
48-
variable "event_target_ecs_target_subnets" {
49-
description = "The subnets associated with the task or service."
50-
type = list
51-
}
52-
53-
variable "event_target_ecs_target_task_definition_arn" {
54-
description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster."
55-
}
56-
57-
variable "ecs_execution_task_role_arn" {
58-
description = "(Required) The task definition execution role"
59-
}
60-
6149
variable "event_target_target_id" {
6250
description = "(Optional) The unique target assignment ID. If missing, will generate a random, unique id."
6351
default = null
6452
}
6553

54+
variable "ecs_cluster_arn" {
55+
description = "The ECS Cluster where the scheduled task will run"
56+
}
57+
6658
variable "event_target_input" {
67-
description = "(Optional) Valid JSON text passed to the target."
59+
description = "(Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path."
6860
default = null
6961
}
7062

7163
variable "event_target_input_path" {
72-
description = "(Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target."
64+
description = " (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event_target_input."
7365
default = null
7466
}
7567

76-
variable "event_target_ecs_target_security_groups" {
77-
description = "(Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used."
78-
type = list
79-
default = []
68+
variable "ecs_execution_task_role_arn" {
69+
description = "(Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered."
8070
}
8171

82-
variable "event_target_ecs_target_assign_public_ip" {
83-
description = "(Optional) Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false."
84-
type = bool
85-
default = false
72+
variable "event_target_ecs_target_group" {
73+
description = "(Optional) Specifies an ECS task group for the task. The maximum length is 255 characters."
74+
default = null
75+
}
76+
77+
variable "event_target_ecs_target_platform_version" {
78+
description = "(Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST"
79+
default = "LATEST"
8680
}
8781

8882
variable "event_target_ecs_target_task_count" {
@@ -91,12 +85,23 @@ variable "event_target_ecs_target_task_count" {
9185
default = 1
9286
}
9387

94-
variable "event_target_ecs_target_platform_version" {
95-
description = "(Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. This is used only if LaunchType is FARGATE. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST"
96-
default = "LATEST"
88+
variable "event_target_ecs_target_task_definition_arn" {
89+
description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster."
9790
}
9891

99-
variable "event_target_ecs_target_group" {
100-
description = "(Optional) Specifies an ECS task group for the task. The maximum length is 255 characters."
92+
variable "event_target_ecs_target_subnets" {
93+
description = "The subnets associated with the task or service."
94+
type = list
95+
}
96+
97+
variable "event_target_ecs_target_security_groups" {
98+
description = "(Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used."
99+
type = list
101100
default = null
102101
}
102+
103+
variable "event_target_ecs_target_assign_public_ip" {
104+
description = "(Optional) Assign a public IP address to the ENI. Default false."
105+
type = bool
106+
default = false
107+
}

0 commit comments

Comments
 (0)