Send alerts from AWS Network Firewall to a Slack channel
Created by Venki Srivatsav (AWS) and Aromal Raj Jayarajan (AWS)
Summary
This pattern describes how to deploy a firewall by using Amazon Web Services (AWS) Network Firewall with the distributed deployment model and how to propagate the alerts generated by AWS Network Firewall to a configurable Slack channel.
Compliance standards such as Payment Card Industry Data Security Standard (PCI DSS) require that you install and maintain a firewall to protect customer data. In the AWS Cloud, a virtual private cloud (VPC) is considered the same as a physical network in the context of these compliance requirements. You can use Network Firewall to monitor network traffic between VPCs and to protect your workloads that run in VPCs governed by a compliance standard. Network Firewall blocks access or generates alerts when it detects unauthorized access from other VPCs in the same account. However, Network Firewall supports a limited number of destinations for delivering the alerts. These destinations include Amazon Simple Storage Service (Amazon S3) buckets, Amazon CloudWatch log groups, and Amazon Data Firehose delivery streams. Any further action on these notifications requires offline analysis by using either Amazon Athena or Amazon Kinesis.
This pattern provides a method for propagating alerts that are generated by Network Firewall to a configurable Slack channel for further action in near real time. You can also extend the functionality to other alerting mechanisms such as PagerDuty, Jira, and email. (Those customizations are outside the scope of this pattern.)
Prerequisites and limitations
Prerequisites
Slack channel (see Getting started
in the Slack help center) Required privileges to send a message to the channel
The Slack endpoint URL with an API token (select your app
and choose an incoming webhook to see its URL; for more information, see Creating an Incoming Webhook in the Slack API documentation) An Amazon Elastic Compute Cloud (Amazon EC2) test instance in the workload subnets
Test rules in Network Firewall
Actual or simulated traffic to trigger the test rules
An S3 bucket to hold the source files to be deployed
Limitations
Currently this solution supports only a single Classless Inter-Domain Routing (CIDR) range as a filter for source and destination IPs.
Architecture
Target technology stack
One VPC
Four subnets (two for the firewall and two for workloads)
Internet gateway
Four route tables with rules
S3 bucket used as an alert destination, configured with a bucket policy and event settings to run a Lambda function
Lambda function with an execution role, to send Slack notifications
AWS Secrets Manager secret for storing the Slack URL
Network firewall with alert configuration
Slack channel
All components except for the Slack channel are provisioned by the CloudFormation templates and the Lambda function that are provided with this pattern (see the Code section).
Target architecture
This pattern sets up a decentralized network firewall with Slack integration. This architecture consists of a VPC with two Availability Zones. The VPC includes two protected subnets and two firewall subnets with network firewall endpoints. All traffic going into and out of the protected subnets can be monitored by creating firewall policies and rules. The network firewall is configured to place all alerts in an S3 bucket. This S3 bucket is configured to call a Lambda function when it receives a put
event. The Lambda function fetches the configured Slack URL from Secrets Manager and sends the notification message to the Slack workspace.

For more information about this architecture, see the AWS blog post Deployment models for AWS Network Firewall
Tools
AWS services
AWS Network Firewall is a stateful, managed, network firewall and intrusion detection and prevention service for VPCs in the AWS Cloud. You can use Network Firewall to filter traffic at the perimeter of your VPC and protect your workloads on AWS.
AWS Secrets Manager is a service for credential storage and retrieval. Using Secrets Manager, you can replace hardcoded credentials in your code, including passwords, with an API call to Secrets Manager to retrieve the secret programmatically. This pattern uses Secrets Manager to store the Slack URL.
Amazon Simple Storage Service (Amazon S3) is an object storage service. You can use Amazon S3 to store and retrieve any amount of data at any time, from anywhere on the web. This pattern uses Amazon S3 to store the CloudFormation templates and Python script for the Lambda function. It also uses an S3 bucket as the network firewall alert destination.
AWS CloudFormation helps you model and set up your AWS resources, provision them quickly and consistently, and manage them throughout their lifecycle. You can use a template to describe your resources and their dependencies, and launch and configure them together as a stack, instead of managing resources individually. This pattern uses AWS CloudFormation to automatically deploy a distributed architecture for Firewall Manager.
Code
The code for this pattern is available on GitHub, in the Network Firewall Slack Integrationsrc
folder of the repository, you’ll find:
A set of CloudFormation files in YAML format. You use these templates to provision the components for this pattern.
A Python source file (
slack-lambda.py
) to create the Lambda function.A .zip archive deployment package (
slack-lambda.py.zip
) to upload your Lambda function code.
To use these files, follow the instructions in the next section.
Epics
Task | Description | Skills required |
---|---|---|
Create an S3 bucket. |
For more information, see Creating a bucket in the Amazon S3 documentation. | App developer, App owner, Cloud administrator |
Upload the CloudFormation templates and Lambda code. |
| App developer, App owner, Cloud administrator |
Task | Description | Skills required |
---|---|---|
Launch the CloudFormation template. | Open the AWS CloudFormation console For more information about deploying CloudFormation templates, see Creating a stack on the AWS CloudFormation console in the CloudFormation documentation. | App developer, App owner, Cloud administrator |
Complete the parameters in the template. | Specify the stack name and configure the parameter values. For a list of parameters, their descriptions, and default values, see CloudFormation parameters in the Additional information section. | App developer, App owner, Cloud administrator |
Create the stack. |
| App developer, App owner, Cloud administrator |
Task | Description | Skills required |
---|---|---|
Test the deployment. | Use the AWS CloudFormation console or the AWS Command Line Interface (AWS CLI) to verify that the resources listed in the Target technology stack section have been created. If the CloudFormation template fails to deploy successfully, check the values you provided for the | App developer, App owner, Cloud administrator |
Test functionality. | 1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ 2. Create an EC2 instance in one of the protected subnets. Choose an Amazon Linux 2 AMI (HVM) to use as an HTTPS server. For instructions, see Launch an instance in the Amazon EC2 documentation. NoteAmazon Linux 2 is nearing end of support. For more information, see the Amazon Linux 2 FAQs 3. Use the following user data to install a web server on the EC2 instance:
4. Create the following network firewall rules: Stateless rule:
Stateful rule:
5. Get the public IP of the web server you created in step 3. 6. Access the public IP in a browser. You should see the following message in the browser:
You will also get a notification in the Slack channel. The notification might be delayed, depending on the size of the message. For testing purposes, consider providing a CIDR filter that is not too narrow (for example, a CIDR value with /32 would be considered too narrow, and /8 would be too broad). For more information, see the Filter behavior section in Additional information. | App developer, App owner, Cloud administrator |
Related resources
Deployment models for AWS Network Firewall
(AWS blog post) AWS Network Firewall policies (AWS documentation)
Network Firewall Slack Integration
(GitHub repository) Create a Slack workspace
(Slack help center)
Additional information
CloudFormation parameters
Parameter | Description | Default or sample value |
---|---|---|
| The name of the VPC to create. | Inspection |
| The CIDR range for the VPC to create. | 10.0.0.0/16 |
| How EC2 instances are distributed across physical hardware. Options are | default |
| The first Availability Zone for the infrastructure. | us-east-2a |
| The second Availability Zone for the infrastructure. | us-east-2b |
| The CIDR range for the first firewall subnet (minimum /28). | 10.0.1.0/24 |
| The CIDR range for the second firewall subnet (minimum /28). | 10.0.2.0/24 |
| The CIDR range for the first protected (workload) subnet. | 10.0.3.0/24 |
| The CIDR range for the second protected (workload) subnet. | 10.0.4.0/24 |
| The name of the existing S3 bucket where you uploaded the Lambda source code. | us-w2-yourname-lambda-functions |
| The prefix of the S3 bucket where you uploaded the Lambda source code. | aod-test |
| The name of the secret that holds the Slack URL. | SlackEnpoint-Cfn |
| The name of the Slack channel you created. | somename-notifications |
| Slack user name. | Slack User |
| This can be any key. We recommend that you use the default. | webhookUrl |
| The value of the Slack URL. | https://hooks.slack.com/services/T???9T??/A031885JRM7/9D4Y?????? |
| The name of the S3 bucket to be used as the network firewall alert destination. This bucket will be created for you. | us-w2-yourname-security-aod-alerts |
| The tag name for the secret. | AppName |
| The tag value for the specified tag name. | LambdaSlackIntegration |
| The filter for the destination CIDR range. For more information, see the next section, Filter behavior. | 10.0.0.0/16 |
| A flag to indicate whether to exclude or include the destination match. For more information, see the next section. Valid values are | include |
| The filter for the source CIDR range to alert. For more information, see the next section. | 118.2.0.0/16 |
| The flag to exclude or include the source match. For more information, see the next section. | include |
Filter behavior
If you haven’t configured any filters in AWS Lambda, all generated alerts are sent to your Slack channel. The source and destination IPs of the generated alerts are matched against the CIDR ranges you configured when you deployed the CloudFormation template. If a match is found, the condition is applied. If either the source or the destination falls within the configured CIDR range and at least one of them is configured with the condition include
, an alert is generated. The following tables provide examples of CIDR values, conditions, and results.
Configured CIDR | Alert IP | Configured | Alert | |
---|---|---|---|---|
Source | 10.0.0.0/16 | 10.0.0.25 | include | Yes |
Destination | 100.0.0.0/16 | 202.0.0.13 | include |
Configured CIDR | Alert IP | Configured | Alert | |
---|---|---|---|---|
Source | 10.0.0.0/16 | 10.0.0.25 | exclude | No |
Destination | 100.0.0.0/16 | 202.0.0.13 | include |
Configured CIDR | Alert IP | Configured | Alert | |
---|---|---|---|---|
Source | 10.0.0.0/16 | 10.0.0.25 | include | Yes |
Destination | 100.0.0.0/16 | 100.0.0.13 | include |
Configured CIDR | Alert IP | Configured | Alert | |
---|---|---|---|---|
Source | 10.0.0.0/16 | 90.0.0.25 | include | Yes |
Destination | Null | 202.0.0.13 | include |
Configured CIDR | Alert IP | Configured | Alert | |
---|---|---|---|---|
Source | 10.0.0.0/16 | 90.0.0.25 | include | No |
Destination | 100.0.0.0/16 | 202.0.0.13 | include |