Log Collection Into Splunk With Control Tower
Log Collection Into Splunk With Control Tower
1
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Notices
Customers are responsible for making their own independent assessment of the
information in this document. This document: (a) is for informational purposes only, (b)
represents current AWS product offerings and practices, which are subject to change
without notice, and (c) does not create any commitments or assurances from AWS and
its affiliates, suppliers or licensors. AWS products or services are provided “as is” without
warranties, representations, or conditions of any kind, whether express or implied. The
responsibilities and liabilities of AWS to its customers are controlled by AWS agreements,
and this document is not part of, nor does it modify, any agreement between AWS and
its customers.
© 2020 Amazon Web Services, Inc. or its affiliates. All rights reserved.
2
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Contents
Overview ..............................................................................................................................4
Considerations .....................................................................................................................6
Scenario ...............................................................................................................................7
Prerequisites ........................................................................................................................7
Shared VPCs for Forwarder Lambda Functions .............................................................7
Code Buckets for Forwarder Lambda Functions.............................................................8
IAM User for the Splunk User ..........................................................................................9
Runbook – Collection of logs from AWS into Splunk .......................................................10
Use Case ........................................................................................................................10
Architecture ........................................................................................................................10
How Each Log Input is Collected and Sent to Splunk ..................................................12
AWS Best Practices Recommended in the Architecture ..............................................14
Mechanism Implementation Guide ...................................................................................15
Automating Installation and Configuration Using CloudFormation StackSets .............20
Updating the Mechanism ...............................................................................................21
Splunk Installation and Configuration Steps .................................................................22
Removing the Mechanism .............................................................................................22
Future Possible Enhancements ........................................................................................24
Conclusion .........................................................................................................................24
Contributors .......................................................................................................................24
Document Revisions..........................................................................................................25
3
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Overview
Splunk is a technology used for application management, security, and compliance, as
well as business and web analytics. Splunk works well to search for specific data in a
large volume of complex data.
The Splunk add-on for AWS enables you to collect:
4
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
The runbook provides steps for updating the AWS CloudFormation StackSet to deploy
the mechanism, or modify the configuration as necessary. It also provides removal
steps for the architecture. Where possible, the mechanism builds an automated
environment.
The runbook also provides guidance on possible enhancements for the mechanism, to
cover more log inputs at the workload level.
5
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
The rest of this document covers each of the prioritized use cases, and documents the
current process, architecture, and tooling used.
Considerations
Familiarity with the following AWS Services is highly recommended:
6
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Scenario
An organization wants to deploy the mechanism in the Northern Hemisphere landing
zone, which is the customer’s region of operations in North America (NA) and Europe,
the Middle East and Africa (EMEA).
AWS regions Ohio (us-east-2), Virginia (us-east-1), Frankfurt (eu-central-1), and Ireland
(eu-west-1) have been selected. Ohio is the NA primary region with Virginia as backup,
and in EMEA Frankfurt is the primary with Ireland as backup.
This multi-account environment has:
Prerequisites
The following prerequisites are required to set up this mechanism.
You will create a VPC with a Classless Inter-Domain Routing (CIDR) range as
x.x.8.0/22.
1. Create the shared subnets for the CIDRs using the third octets 8,9, and 10 as
/24 blocks.
2. Share the subnets with the organization using AWS Resource Access Manager
(AWS RAM).
3. Create the AWS Transit Gateway attachment for the Amazon VPC which allows
for connectivity on-premises.
7
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
4. Update the Amazon VPC route table to allow a route back to the organization’s
on-premises addresses.
5. Select range /22 for the Amazon VPC, anticipating the addition of accounts in
the AWS Control Tower environment, with added forwarder Lambda functions in
each account that reside in this shared Amazon VPC for each region.
Forwarder Lambda functions no longer require this shared Amazon VPC if the
organization is using Splunk cloud on AWS, and has the required network connectivity
for Lambda functions to talk to Splunk. They use the AWS backbone to communicate
with Splunk instances as they communicate with other AWS services.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3::: s3-bucket-name-splunk-cust-
frankfurt/*",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "org-id "
}
}
}
]
}
8
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
All the S3 code buckets are encrypted using the regional AWS Key Management
Service (AWS KMS) keys created in the same shared IT support account.
9
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Architecture
As of the date of this publication, Splunk collects log inputs from the following 9 AWS
sources:
10
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Figure 2 illustrates the various mechanisms configured for Splunk to collect log data
from the AWS accounts.
Figure 2 —AWS log collection with AWS Control Tower into Splunk
The mechanisms are centrally deployed into each account, either by AWS
CloudFormation or AWS CloudFormation StackSets. The Log-Archive account is the
central collector. It aggregates logs from all the regions and member accounts. The logs
are stored in S3 buckets in the us-east-2 Region, which send notifications to SQS
queues which are polled by Splunk every five minutes for log data.
Each member account has local S3 buckets for collecting log data in each of the four
regions. These local buckets replicate log data to the central S3 buckets in the Log-
Archive account.
Log inputs such as CloudTrail, AWS Config, S3, ELB, Amazon VPC Flow Logs, and
GuardDuty are centrally collected into the Log-Archive in the us-east-2 Region.
CloudWatch metrics, CloudWatch logs, and AD logs are individually forwarded from
each AWS account in all the AWS Regions directly to a HEC.
11
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Splunk pulls these logs using an SQS-based S3 input mechanism. New object
notifications are sent to SQS. Splunk polls the queue to discover new log items, then
ingests them from the S3 bucket.
AWS Config
AWS Control Tower collects AWS Config logs from all accounts in all four AWS regions,
and puts the log data in the central S3 bucket in the Log-Archive account. This is the
same bucket where CloudTrail logs are stored.
Splunk pulls these logs by using the same SQS-based S3 input mechanism.
CloudWatch Metrics
AWS accounts have Cloudwatch Metrics, which can be directly pulled by Splunk from
each individual account in all the AWS regions.
CloudWatch Logs
CloudWatch logs are subscribed by a subscriber Lambda function and sent to a
Splunk HEC by a forwarder Lambda function in each individual account, in all the
AWS Regions.
S3 Access Logs
S3 access logs are collected locally in each region in each member account and
replicated to the central S3 log bucket in the Log-Archive account in the us-east-2
Region.
There is a Lambda function to enable S3 logging on newly created S3 buckets. The
target bucket is the local S3 logging bucket in the same Region.
12
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
ELB Logs
ELB logs are collected locally in each Region in each member account, and replicated
to the central S3 log bucket in the Log-Archive account in the us-east-2 Region.
There is a Lambda function to enable ELB logging on newly created ELBs. The
destination bucket is the local S3 logging bucket in the same Region.
Amazon VPC Flow logs generate a lot of log data, so we don’t recommend that you
generate them from each account and each region. GuardDuty analyzes Amazon VPC
Flow logs to create findings. There is a template to deploy in the necessary production
accounts, or for critical workloads to create Amazon VPC Flow logs.
As of the date of this publication, Amazon VPC Flow logs are created in the primary
account for AWS Managed Microsoft AD VPC and sent to the central Log-Archive in
us-east-2 from all the Regions.
13
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
• Although Splunk ingests AWS logs from all the accounts in the AWS Control
Tower, only one IAM user is created for the Splunk service, with a policy to
assume the AWS Splunk role in other accounts.
IAM Roles for Cross Account Access
• IAM roles enable you to delegate access with defined permissions to trusted
entities without having to share long-term access keys. You can use IAM roles to
delegate access to:
o IAM users managed within your account
o IAM users under a different AWS account
o An AWS service like Amazon EC2
• The AWS Splunk role in each account only has a trust-relationship with the
central Splunk user.
Data Protection
14
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
• AWS Config
• CloudTrail
• CloudWatch
• Directory Service
• ELB
• GuardDuty
• IAM (user, roles and policies)
• KMS
• S3
• SQS
For networking, Amazon VPC, AWS Transit Gateway and VPN/DirectConnect are also
used.
Excepting IAM and S3, the previously mentioned services are regional, so the
necessary controls, processes, event rules, and infrastructure must be set up in every
region where AWS Services will leverage CloudWatch logging and monitoring.
One important aspect of the mechanism is that the logs from all the other regions and
individual AWS member accounts are collected in the central Log-Archive account in
the us-east-2 region. The exceptions are CloudWatch logs and metrics. CloudWatch
metrics are pulled directly from accounts, and CloudWatch logs are forwarded to the
Splunk HEC from the source accounts.
Code Repository
The code can be downloaded from this secure S3 bucket. The ZIP file contains a folder
called aws-splunk-whitepaper with the following structure:
src
• ELBLogger
o index.py
15
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
• Forwarder
o SplunkForwarderLambdaV44.zip
o SplunkForwarderLambdaV45.zip
• S3Logger
o index.py
• Subscriber
o index.py
architecture-diagrams
• AWS Splunk Architecture Diagram.png
templates
• aws-account-baseline
o aws-splunk-global-resources-cust-logging.yaml
o aws-splunk-local-resources-cust-logging-emea.yaml
o aws-splunk-local-resources-cust-logging-na.yaml
• log-archive
o cust-splunk-role.yaml
o kms-splunk-key.yaml
o splunk-queues-and-buckets.yaml
o splunk-vpcflow-guardduty-buckets-queues.yaml
o bucket-policy-gd-vpcflowlogs
vpc-flow-log-bucket-policy.json
guard-duty-bucket-policy.json
• vpcflowlogs
o flowlogs.yaml
• cwlogs
o cw-logs-ad-splunk_emea.yaml
o cw-logs-ad-splunk_na.yaml
16
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
o cw-logs-global-roles.yaml
The folder also contains a readme.MD file.
The code repository has the Lambda function code used inline in the CloudFormation
templates. For forwarder Lambda functions, the zip file is stored in the S3 code
bucket.
In the CloudFormation templates, look for cust. Replace cust with the customer name.
Replace S3bucket names with your bucket name Amazon Resource Names (ARNs) as
necessary. Update the KMS ARNs in the bucket policies as well. Use the Amazon VPC
and subnet IDs that you create to wrap the forwarder Lambda functions in a VPC.
Deployment
The mechanism can be deployed to customer Organizational Units (OUs) so it will
collect logs from all the child accounts.
The 6 inputs (Config, CloudTrail, S3, ELB, CloudWatch logs, CloudWatch Metrics) can
be deployed using CloudFormation StackSets deployed in the AWS Control Tower
primary account in the Region us-east-2.
The other three inputs (Microsoft AD, GuardDuty and Amazon VPC Flow logs) are
deployed in specific accounts using CloudFormation stacks:
• Microsoft AD logs are sent via CloudWatch logs to Splunk from the primary
account.
• Amazon VPC Flow logs are set up with a central bucket and queue in the Log-
Archive in the us-east-2 Region, but only generated for the Microsoft AD VPC in
the primary account.
• GuardDuty findings are collected only from the GuardDuty administrator account
and sent to a central bucket and queue in the Log-Archive account in the us-
east-2 Region.
The correct order of deployment is to create resources in the Log-Archive account
first, then deploy the global resources and the local resources in the member accounts.
For deploying the specific CloudFormation stacks in the core and member accounts,
you must use the Switch Role functionality to login with the
AWSControlTowerExecution role. The AWSControlTowerExecution role allows
AWS Control Tower to manage your individual accounts, and report information about
them to your audit and logging accounts.
AWSControlTowerExecution allows auditing by the AWS Control Tower audit
account, and helps you configure your organization’s logging so that all the logs for
every account are sent to the logging account.
17
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
• templates
• log-archive
• bucket-policy-gd-vpcflowlogs
• vpc-flow-log-bucket-policy.json
2. In all the member accounts, the following CloudFormation template needs to be
deployed for creation of global resources:
• aws-splunk-global-resources-cust-logging.yaml
18
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Steps 3 and 4 can be combined to deploy local resources in all the AWS
NA regions and AWS EMEA regions at once. They are deployed
separately because, if there is a future need to provide different HEC
inputs or other parameters that need to vary for regions, they can simply
be updated by the StackSet deployed in those regions.
Steps 1-4 work to set up the central buckets and queues for all the log
inputs, and deploy local resources for the six log inputs. For the rest of the
inputs like GuardDuty, VPC Flow logs, and Managed AD logs, follow the
next steps.
19
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
The reason you see two different stacks for the EMEA and NA regions is
because the S3 code bucket in the IT support account for forwarder
Lambda functions now has different code versions. It can provide different
input parameters, or mapping specific to the region for future use.
To enable VPC Flow logs in an account, deploy the following template in that
account and provide the Amazon VPC ID in the input parameters. Amazon VPC
flow logs are currently enabled in the primary account for the Amazon VPC in
which Managed Microsoft AD exists. Amazon VPC flow logs are enabled in all
regions and are sent to the central log-bucket in us-east-2 Region:
• flowlogs.yaml
7. For exporting GuardDuty findings, the only step required after creating the
GuardDuty buckets and queues in the Log-Archive account is to set up the
export configuration in all the required AWS Regions in the GuardDuty primary
account.
Updating Configuration
Any time there’s a need to change the configuration or update input parameters for a
particular region or account, it is recommended that you make changes using the
Update CloudFormation Stack or StackSet to avoid drift.
20
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
21
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Configuring Permissions
Manage accounts and configure inputs for the Splunk Add-on for AWS.
Networking Endpoints
Ensure that the on-premises Splunk server is permitted through corporate firewalls to
access the AWS service endpoints, so it can poll for data. See more information about
the AWS service endpoints.
Configuring Inputs
See best practices and details on how to configure inputs on the Splunk Add-on for
AWS page.
• If you need to remove the mechanism from all accounts in all regions, after you
have deleted the stacks, delete the StackSets from the primary account.
• Make sure to empty S3 buckets before you delete them.
22
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
• Delete the Log-Archive account resources after you delete local resources in
member accounts.
• Delete the stacks deployed in the Log-Archive account.
Steps to be performed manually:
1. Delete S3 code buckets in IT support account created for forwarder Lambda
functions.
23
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
2. After you remove the CloudWatch logs for subscriber Lambda functions, you can
delete the shared VPCs and the Resource Access Manager shares in the IT
support account.
3. Once everything else has been deleted, you can delete the IAM user for Splunk
in the Log-Archive account.
Remember to manually delete the resources created in the shared IT Support account.
• CloudFront logs
• AWS Web Application Firewall (AWS WAF) logs
• Amazon EC2 Auto Scaling logs
• Amazon RDS logs
Typically, these log inputs are workload specific and can be deployed in the necessary
production accounts using CloudFormation stacks, or in production OUs using
CloudFormation Stacksets.
Conclusion
We have provided an architecture to collect AWS logs from multiple AWS resources into
a central account in AWS and sent to the SIEM tool Splunk. The solution provided is a
fully automated mechanism leveraging an Infrastructure as Code (IaC) mechanism.
Leveraging the AWS CloudFormation Stacksets for provisioning and AWS Lambda for
its serverless benefits, the implementation is easy to deploy, configurable, and can be
updated as necessary. It can be extended for more log inputs, and will be added to the
new AWS Accounts and AWS Regions.
Contributors
Contributors to this document include:
24
Amazon Web Services AWS Log Collection into Splunk Integrated with AWS Control Tower
Document Revisions
Date Description
November 2020 First publication
25