Coder Social home page Coder Social logo

avinashmamidi / serverless-guardduty-findings-to-sns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miztiik/serverless-guardduty-findings-to-sns

0.0 1.0 1.0 232 KB

A lambda function to push GuardDuty Findings to SNS Topic ๐ŸŽ“

Home Page: https://www.udemy.com/course/aws-cloud-security-proactive-way/?referralCode=71DC542AD4481309A44

Python 100.00%

serverless-guardduty-findings-to-sns's Introduction

Amazon GuardDuty Findings to SNS

Every GuardDuty finding is assigned a finding ID. For every finding with a unique finding ID, GuardDuty aggregates all subsequent occurrences of a particular finding that take place in six-hour intervals into a single event. GuardDuty then sends a notification about these subsequent occurrences based on this event. We can use this to push the notifications into SNS topic, and getting the security teams to investigate the findings.

Fig : Amazon GuardDuty Findings to SNS

This AWS Lambda function will help you to automatically push GuardDuty findings to an SNS topic which can be used by ITSM tools for their workflows.

Follow this article in Youtube

Pre-Requisities

We will need the following pre-requisites to successfully complete this activity,

  • A SNS topic to which our lambda will publish the GuardDuty Findings. Help for setting up SNS Topic
    • <ARN-OF-YOUR-SNS-TOPIC> - We need this to update in the IAM Policy
    • An email address already subscribed to this topic
  • IAM Role - i.e Lambda Service Role - with two permissions; Help for setting up IAM Role
    • AWSLambdaBasicExecutionRole - To allow Lambda to log events
    • InlinePolicy - To allow Lambda to publish to SNS topic

Step 0: IAM Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "<ARN-OF-YOUR-SNS-TOPIC>"
        }
    ]
}

Step 1 - Configure Lambda Function- Serverless Janitor

The python script is written(and tested) in Python 3.6. Remember to choose the same in AWS Lambda Functions.

Customisations

  • Change the global variables at the top of the script to suit your needs.

    • globalVars['SNSTopicArn']] - Update the code with your <ARN-OF-YOUR-SNS-TOPIC>; you can also do that using Lambda Environment variables
  • Copy the code from Serverless-GuardDuty-Findings-To-SNS in this repo to the lambda function

    • Consider increasing the lambda run time as needed, the default is 3 seconds.
  • Save the lambda function

Step 2 - Configure Lambda Triggers

Goto the Cloudwatch Dashboard, We are going to use Event Rules

  1. Choose Create a new Rule
  2. For Event Source - Choose Event pattern
    1. For Service, Choose/Type GuardDuty
    2. For Event Type, Choose GuardDuty Finding
  3. For Target, Choose Lambda Function
    1. From dropdown select your Lambda Function Name
  4. In the bottom, Configure Details
  5. Fill the Rule Name & Rule Description
    1. Make sure it is Enabled
  6. Enable Trigger by Checking the box
  7. Click Save

Now your lambda function should be triggered when ever there is a GuardDuty Findings

Step 3 - Testing the solution

Goto GuardDuty Dashboard. Here we can generate some sample findings from Settings Tab.

Or if you want more sophisticated testing, try out this If you dont have any, considering trying out my Serverless AMI Baker.

Summary

We have demonstrated how you can automatically push the findings to SNS Topic.

serverless-guardduty-findings-to-sns's People

Contributors

avinashmamidi avatar miztiik avatar

Watchers

 avatar

Forkers

omonigho4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.