|
| 1 | +--- |
| 2 | +title: Ingest CloudWatch logs to Microsoft Sentinel - create a Lambda function to send CloudWatch events to S3 bucket |
| 3 | +description: In this article, you create a Lambda function to send CloudWatch events to an S3 bucket. |
| 4 | +author: limwainstein |
| 5 | +ms.author: lwainstein |
| 6 | +ms.service: microsoft-sentinel |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 02/09/2023 |
| 9 | +#Customer intent: As a security operator, I want to create a Lambda function to send CloudWatch events to S3 bucket so I can convert the format to the format accepted by Microsoft Sentinel. |
| 10 | +--- |
| 11 | + |
| 12 | +# Create a Lambda function to send CloudWatch events to an S3 bucket |
| 13 | + |
| 14 | +In some cases, your CloudWatch logs may not match the format accepted by Microsoft Sentinel - .csv file in a GZIP format without a header. In this article, you use a [lambda function](https://github.com/Azure/Azure-Sentinel/blob/master/DataConnectors/AWS-S3/CloudWatchLanbdaFunction.py) within the Amazon Web Services (AWS) environment to send [CloudWatch events to an S3 bucket](connect-aws.md), and convert the format to the accepted format. |
| 15 | + |
| 16 | +## Create the lambda function |
| 17 | + |
| 18 | +The lambda function uses Python 3.9 runtime and x86_64 architecture. |
| 19 | + |
| 20 | +1. In the AWS Management Console, select the lambda service. |
| 21 | +1. Select **Create function**. |
| 22 | + |
| 23 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-basic-information.png" alt-text="Screenshot of the AWS Management Console Basic information screen." lightbox="media/cloudwatch-lambda-function/lambda-basic-information.png"::: |
| 24 | + |
| 25 | +1. Type a name for the function and select **Python 3.9** as the runtime and **x86_64** as the architecture. |
| 26 | +1. Select **Create function**. |
| 27 | +1. Under **Choose a layer**, select a layer and select **Add**. |
| 28 | + |
| 29 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-add-layer.png" alt-text="Screenshot of the AWS Management Console Add layer screen." lightbox="media/cloudwatch-lambda-function/lambda-add-layer.png"::: |
| 30 | + |
| 31 | +1. Select **Permissions**, and under **Execution role**, select **Role name**. |
| 32 | +1. Under **Permissions policies**, select **Add permissions** > **Attach policies**. |
| 33 | + |
| 34 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-permissions.png" alt-text="Screenshot of the AWS Management Console Permissions tab." lightbox="media/cloudwatch-lambda-function/lambda-permissions.png"::: |
| 35 | + |
| 36 | +1. Search for the *AmazonS3FullAccess* and *CloudWatchLogsReadOnlyAccess* policies and attach them. |
| 37 | + |
| 38 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-other-permissions-policies.png" alt-text="Screenshot of the AWS Management Console Add permissions policies screen." lightbox="media/cloudwatch-lambda-function/lambda-other-permissions-policies.png"::: |
| 39 | + |
| 40 | +1. Copy the code link from the [source file](https://github.com/Azure/Azure-Sentinel/blob/master/DataConnectors/AWS-S3/CloudWatchLanbdaFunction.py). |
| 41 | +1. Return to the function, select **Code**, and paste the code link under **Code source**. |
| 42 | + |
| 43 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-code-source.png" alt-text="Screenshot of the AWS Management Console Code source screen." lightbox="media/cloudwatch-lambda-function/lambda-code-source.png"::: |
| 44 | + |
| 45 | +1. Fill the parameters as required. |
| 46 | +1. Select **Deploy**, and then select **Test**. |
| 47 | +1. Create an event by filling in the required fields. |
| 48 | + |
| 49 | + :::image type="content" source="media/cloudwatch-lambda-function/lambda-configure-test-event.png" alt-text="Screenshot of the AWS Management Configure test event screen." lightbox="media/cloudwatch-lambda-function/lambda-configure-test-event.png"::: |
| 50 | + |
| 51 | +1. Select **Test** to see how the event appears in the S3 bucket. |
| 52 | + |
| 53 | +## Next steps |
| 54 | + |
| 55 | +In this document, you learned how to create a Lambda function to send CloudWatch events to an S3 bucket. To learn more about Microsoft Sentinel, see the following articles: |
| 56 | +- Learn how to [get visibility into your data, and potential threats](get-visibility.md). |
| 57 | +- Get started [detecting threats with Microsoft Sentinel](detect-threats-built-in.md). |
| 58 | +- [Use workbooks](monitor-your-data.md) to monitor your data. |
0 commit comments