From 578b4a40d8613143cd4138849e6b2e4039d60ad6 Mon Sep 17 00:00:00 2001 From: aloftus23 Date: Wed, 11 Dec 2024 08:23:24 -0500 Subject: [PATCH] Revert "Remove serverless resources" This reverts commit 1ccb61d0e112e937bfccb7aaa30453cc6887690a. --- backend/serverless.yml | 49 +++++++++++++++++++++++++++ backend/src/api/functions.yml | 13 +++++++ backend/src/tasks/functions.yml | 60 +++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) diff --git a/backend/serverless.yml b/backend/serverless.yml index 5c6625a9..eb5f0437 100644 --- a/backend/serverless.yml +++ b/backend/serverless.yml @@ -110,6 +110,55 @@ provider: - ssm:PutParameter Resource: '*' +resources: + Resources: + ShodanQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-shodan-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + DnstwistQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-dnstwist-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + IntelxQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-intelx-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + CybersixgillQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-cybersixgill-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + XpanseQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-xpanse-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + ASMQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: ${self:provider.stage}-asm-queue + VisibilityTimeout: 18000 # 5 hours + MaximumMessageSize: 262144 # 256 KB + MessageRetentionPeriod: 604800 # 7 days + +functions: + - ${file(./src/tasks/functions.yml)} + - ${file(./src/api/functions.yml)} + plugins: - serverless-domain-manager - serverless-dotenv-plugin diff --git a/backend/src/api/functions.yml b/backend/src/api/functions.yml index e69de29b..10d6fbb8 100644 --- a/backend/src/api/functions.yml +++ b/backend/src/api/functions.yml @@ -0,0 +1,13 @@ +--- +api: + handler: src/api.handler + events: + - http: + path: / # this matches the base path + method: ANY + cors: true + - http: + # this matches any path, the token 'any' doesn't mean anything special + path: /{any+} + method: ANY + cors: true diff --git a/backend/src/tasks/functions.yml b/backend/src/tasks/functions.yml index e69de29b..bd5ee23b 100644 --- a/backend/src/tasks/functions.yml +++ b/backend/src/tasks/functions.yml @@ -0,0 +1,60 @@ +--- +cloudwatchToS3: + handler: src/tasks/cloudwatchToS3.handler + timeout: 900 + events: + - schedule: rate(4 hours) + reservedConcurrency: 1 + memorySize: 4096 + +scheduler: + handler: src/tasks/scheduler.handler + timeout: 900 + events: + - schedule: rate(5 minutes) + reservedConcurrency: 1 + memorySize: 4096 + +syncdb: + timeout: 900 + handler: src/tasks/syncdb.handler + +pesyncdb: + timeout: 900 + handler: src/tasks/pesyncdb.handler + +syncmdl: + timeout: 900 + handler: src/tasks/syncmdl.handler + +bastion: + timeout: 900 + handler: src/tasks/bastion.handler + +makeGlobalAdmin: + handler: src/tasks/makeGlobalAdmin.handler + +checkUserExpiration: + timeout: 300 + handler: src/tasks/checkUserExpiration.handler + events: + - schedule: cron(0 0 * * ? *) # Runs every day at midnight + +scanExecution: + timeout: 900 # 15 minutes + handler: src/tasks/scanExecution.handler + memorySize: 4096 + +updateScanTaskStatus: + handler: src/tasks/updateScanTaskStatus.handler + events: + - eventBridge: + name: ${self:provider.stage}-updateScanTaskStatus + pattern: + source: + - aws.ecs + detail-type: + - ECS Task State Change + detail: + clusterArn: + - ${file(env.yml):${self:provider.stage}-ecs-cluster, ''}