From 4a085ae4ad35cdb30196aaf1be6d252dba265e80 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 30 Apr 2021 21:47:52 +0300
Subject: [PATCH] Don't create the alarms before the triggere are created.

The triggers will be created last (after the rule, the functions and the
aliases are created). Without them, there won't be any invocations and
obviously the alarms will trigger.
---
 alarms.tf | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/alarms.tf b/alarms.tf
index b236cde..274ac9a 100644
--- a/alarms.tf
+++ b/alarms.tf
@@ -17,6 +17,10 @@ resource "aws_cloudwatch_metric_alarm" "invocations" {
   dimensions = {
     FunctionName = local.function_names[count.index]
   }
+
+  depends_on = [
+    aws_cloudwatch_event_target.schedule,
+  ]
 }
 
 resource "aws_cloudwatch_metric_alarm" "errors" {
@@ -38,4 +42,8 @@ resource "aws_cloudwatch_metric_alarm" "errors" {
   dimensions = {
     FunctionName = local.function_names[count.index]
   }
+
+  depends_on = [
+    aws_cloudwatch_event_target.schedule,
+  ]
 }
-- 
GitLab