Эх сурвалжийг харах

Adjustments for Portal Lambda

Brad Poulton 3 жил өмнө
parent
commit
2bb89fc35e

+ 24 - 1
base/customer_portal_lambda/cloudwatch.tf

@@ -23,6 +23,14 @@ resource "aws_cloudwatch_event_rule" "portal_scheduler_quarter_hourly_rule" {
   tags = merge(var.standard_tags, var.tags)
 }
 
+resource "aws_cloudwatch_event_rule" "portal_scheduler_third_hourly_rule" {
+  name = "aws-portal-lambda-scheduler-third-hourly"
+  description = "Rule for portal scheduler lambda function - every 20th minute"
+  schedule_expression = "cron(0/20 * * * ? *)"
+  is_enabled = var.environment == "test" ? false : true
+  tags = merge(var.standard_tags, var.tags)
+}
+
 resource "aws_cloudwatch_event_rule" "portal_scheduler_half_hourly_rule" {
   name = "aws-portal-lambda-scheduler-half-hourly"
   description = "Rule for portal scheduler lambda function - every 30 minutes"
@@ -66,7 +74,7 @@ resource "aws_cloudwatch_event_rule" "portal_scheduler_weekly_rule" {
 resource "aws_cloudwatch_event_rule" "portal_scheduler_monthly_rule" {
   name = "aws-portal-lambda-scheduler-monthly"
   description = "Rule for portal scheduler lambda function - every month"
-  schedule_expression = "rate(30 days)"
+  schedule_expression = "cron(0 17 1 * ? *)"
   is_enabled = var.environment == "test" ? false : true
   tags = merge(var.standard_tags, var.tags)
 }
@@ -79,6 +87,13 @@ resource "aws_cloudwatch_event_target" "portal_scheduler_cloudwatch_target_quart
   arn  = aws_lambda_function.portal_scheduler.arn
 }
 
+resource "aws_cloudwatch_event_target" "portal_scheduler_cloudwatch_target_third_hourly" {
+  target_id = "PortalSchedulerThirdHourly"
+  rule = aws_cloudwatch_event_rule.portal_scheduler_third_hourly_rule.name
+  input = "{\"frequency_identifier\":\"threat-q-twenty-minute\"}"
+  arn  = aws_lambda_function.portal_scheduler.arn
+}
+
 resource "aws_cloudwatch_event_target" "portal_scheduler_cloudwatch_target_half_hourly" {
   target_id = "PortalSchedulerHalfHourly"
   rule = aws_cloudwatch_event_rule.portal_scheduler_half_hourly_rule.name
@@ -131,6 +146,14 @@ resource "aws_lambda_permission" "allow_cloudwatch_to_call_portal_scheduler_quar
   source_arn    = aws_cloudwatch_event_rule.portal_scheduler_quarter_hourly_rule.arn
 }
 
+resource "aws_lambda_permission" "allow_cloudwatch_to_call_portal_scheduler_third_hourly" {
+  statement_id  = "AllowExecutionFromCloudWatchThirdHourly"
+  action        = "lambda:InvokeFunction"
+  function_name = aws_lambda_function.portal_scheduler.function_name
+  principal     = "events.amazonaws.com"
+  source_arn    = aws_cloudwatch_event_rule.portal_scheduler_third_hourly_rule.arn
+}
+
 resource "aws_lambda_permission" "allow_cloudwatch_to_call_portal_scheduler_half_hourly" {
   statement_id  = "AllowExecutionFromCloudWatchHalfHourly"
   action        = "lambda:InvokeFunction"

+ 1 - 0
base/customer_portal_lambda/main.tf

@@ -94,6 +94,7 @@ resource "aws_lambda_function" "portal_customer_sync" {
   handler          = "lambda_function.handler"
   runtime          = "python3.8"
   timeout          = "900"
+  memory_size      = "1024" 
   vpc_config {
     subnet_ids          = var.subnets
     security_group_ids  = [ data.aws_security_group.typical-host.id, aws_security_group.portal_lambda_splunk_sg.id ]