Browse Source

Adds 4-hourly Job to Data Sync

Also tags everything

To be tagged v2.1.10
Fred Damstra [afs macbook] 3 years ago
parent
commit
7c97e4bcba
1 changed files with 22 additions and 0 deletions
  1. 22 0
      base/customer_portal_lambda/cloudwatch.tf

+ 22 - 0
base/customer_portal_lambda/cloudwatch.tf

@@ -1,6 +1,7 @@
 resource "aws_cloudwatch_log_group" "function" {
 resource "aws_cloudwatch_log_group" "function" {
   name              = "/aws/lambda/${aws_lambda_function.portal_data_sync.function_name}"
   name              = "/aws/lambda/${aws_lambda_function.portal_data_sync.function_name}"
   retention_in_days = 14
   retention_in_days = 14
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 ###
 ###
@@ -13,6 +14,7 @@ resource "aws_cloudwatch_event_rule" "portal_event_quarter_hourly_rule" {
   description = "Rule for portal data sync lambda function - every 15 minutes"
   description = "Rule for portal data sync lambda function - every 15 minutes"
   schedule_expression = "rate(15 minutes)"
   schedule_expression = "rate(15 minutes)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 resource "aws_cloudwatch_event_rule" "portal_event_half_hourly_rule" {
 resource "aws_cloudwatch_event_rule" "portal_event_half_hourly_rule" {
@@ -20,6 +22,7 @@ resource "aws_cloudwatch_event_rule" "portal_event_half_hourly_rule" {
   description = "Rule for portal data sync lambda function - every 30 minutes"
   description = "Rule for portal data sync lambda function - every 30 minutes"
   schedule_expression = "rate(30 minutes)"
   schedule_expression = "rate(30 minutes)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 resource "aws_cloudwatch_event_rule" "portal_event_hourly_rule" {
 resource "aws_cloudwatch_event_rule" "portal_event_hourly_rule" {
@@ -27,6 +30,15 @@ resource "aws_cloudwatch_event_rule" "portal_event_hourly_rule" {
   description = "Rule for portal data sync lambda function - every hour"
   description = "Rule for portal data sync lambda function - every hour"
   schedule_expression = "rate(1 hour)"
   schedule_expression = "rate(1 hour)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
+}
+
+resource "aws_cloudwatch_event_rule" "portal_event_four_hourly_rule" {
+  name = "aws-portal-lambda-data-sync-four-hourly"
+  description = "Rule for portal data sync lambda function - every 4 hours"
+  schedule_expression = "rate(4 hours)"
+  is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 resource "aws_cloudwatch_event_rule" "portal_event_daily_rule" {
 resource "aws_cloudwatch_event_rule" "portal_event_daily_rule" {
@@ -34,6 +46,7 @@ resource "aws_cloudwatch_event_rule" "portal_event_daily_rule" {
   description = "Rule for portal data sync lambda function - every day"
   description = "Rule for portal data sync lambda function - every day"
   schedule_expression = "cron(5 5 * * ? *)"
   schedule_expression = "cron(5 5 * * ? *)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 resource "aws_cloudwatch_event_rule" "portal_event_weekly_rule" {
 resource "aws_cloudwatch_event_rule" "portal_event_weekly_rule" {
@@ -41,6 +54,7 @@ resource "aws_cloudwatch_event_rule" "portal_event_weekly_rule" {
   description = "Rule for portal data sync lambda function - every week"
   description = "Rule for portal data sync lambda function - every week"
   schedule_expression = "rate(7 days)"
   schedule_expression = "rate(7 days)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 resource "aws_cloudwatch_event_rule" "portal_event_monthly_rule" {
 resource "aws_cloudwatch_event_rule" "portal_event_monthly_rule" {
@@ -48,6 +62,7 @@ resource "aws_cloudwatch_event_rule" "portal_event_monthly_rule" {
   description = "Rule for portal data sync lambda function - every month"
   description = "Rule for portal data sync lambda function - every month"
   schedule_expression = "rate(30 days)"
   schedule_expression = "rate(30 days)"
   is_enabled = var.environment == "test" ? false : true
   is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
 }
 }
 
 
 ### Time-based targets for portal sync:
 ### Time-based targets for portal sync:
@@ -72,6 +87,13 @@ resource "aws_cloudwatch_event_target" "portal_lambda_cloudwatch_target_hourly"
   arn  = aws_lambda_function.portal_data_sync.arn
   arn  = aws_lambda_function.portal_data_sync.arn
 }
 }
 
 
+resource "aws_cloudwatch_event_target" "portal_lambda_cloudwatch_target_four_hourly" {
+  target_id = "PortalSyncFourHourly"
+  rule = aws_cloudwatch_event_rule.portal_event_four_hourly_rule.name
+  input = "{\"frequency_identifier\":\"four-hourly\"}"
+  arn  = aws_lambda_function.portal_data_sync.arn
+}
+
 resource "aws_cloudwatch_event_target" "portal_lambda_cloudwatch_target_daily" {
 resource "aws_cloudwatch_event_target" "portal_lambda_cloudwatch_target_daily" {
   target_id = "PortalSyncDaily"
   target_id = "PortalSyncDaily"
   rule = aws_cloudwatch_event_rule.portal_event_daily_rule.name
   rule = aws_cloudwatch_event_rule.portal_event_daily_rule.name