AWS Trusted Advisor
AWS Trusted Advisor helps users optimize their AWS environment by following AWS best practices and providing real-time guidance to reduce costs, improve performance, and enhance security. Trusted Advisor logs reach an S3 bucket through Amazon EventBridge and Amazon Data Firehose. Wazuh collects them and indexes each check result as an event. To raise findings from these events, create custom rules.
Note
You must have an AWS Business Support+, AWS Enterprise Support, or AWS Unified Operations plan to create an EventBridge rule for Trusted Advisor checks. Trusted Advisor sends all its events to EventBridge in US East (N. Virginia), so create the EventBridge rule and the Firehose stream in that Region. For more information, see changing AWS support plans.
AWS configuration
The following sections cover how to configure the different services required to integrate Trusted Advisor into Wazuh. The following diagram shows how Trusted Advisor events reach the S3 bucket through Amazon EventBridge and Amazon Data Firehose. Wazuh then collects them from the bucket.
Amazon Data Firehose configuration
Create an Amazon Data Firehose delivery stream to store the Trusted Advisor logs into the desired S3 bucket so Wazuh can process them.
Create a new S3 bucket, or skip this step to use an existing bucket.
On your AWS console, search for
amazon data firehosein the search bar or go to Services > Analytics > Amazon Data Firehose.
Click Create Firehose stream.
Select Direct PUT and Amazon S3 as the desired Source and Destination, respectively, and choose an appropriate Firehose stream name.
Select the desired S3 bucket as the destination. You can specify a custom prefix to change the path where AWS stores the logs. Amazon Data Firehose creates a file structure
YYYY/MM/DD/HH. If you use a prefix, the file structure isprefix-name/YYYY/MM/DD/HH, and you must enter the same prefix as the path value in the Wazuh configuration. In this example, the prefix istrusted-advisor/.
Create or choose an existing IAM role to be used by Amazon Data Firehose in the Advanced settings section.
Click Create Firehose stream at the end of the page.
Amazon EventBridge configuration
Configure an Amazon EventBridge rule to send Trusted Advisor events to the Amazon Data Firehose delivery stream created in the previous step.
On your AWS console, search for
eventbridgein the search bar or go to Services > Application Integration > Amazon EventBridge.
Select Event buses, under Default event bus, click default, then click Create rule.
Select Advanced builder, assign a name to the EventBridge rule, and click Next.
In the Build event pattern section, choose AWS events or EventBridge partner events as Event source.
In the Event pattern section, choose AWS services as Event source, Trusted Advisor as AWS service, and All Events as Event type. Click Next.
Under Select a target, choose Firehose stream and select the stream created previously. Also, create a new role to access the delivery stream. Click Next.
Review the configuration and click Create rule.
After you create the rule, EventBridge sends each Trusted Advisor event to the specified S3 bucket. Make sure you enable the Trusted Advisor service, as described in the next section; otherwise, you won't get any data.
AWS Trusted Advisor configuration
On your AWS console, search for
trusted advisorin the search bar or go to Services > Management & Governance > Trusted Advisor.
Go to Manage Trusted Advisor in the left menu and click Enabled.
After you enable it, Trusted Advisor reviews the different checks for the AWS account. Check the official AWS documentation to learn more about the available Trusted Advisor checks.
Policy configuration
Follow the creating an AWS policy guide to create a policy using the Amazon Web Services console.
The policies below follow the principle of least privilege, so they give the AWS IAM user only the minimum permissions it needs.
To allow an AWS user to use the Wazuh module for AWS with read-only permissions, it must have a policy like the following attached:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::<WAZUH_AWS_BUCKET>/*",
"arn:aws:s3:::<WAZUH_AWS_BUCKET>"
]
}
]
}
To delete the log files after Wazuh collects them, use the following policy instead:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::<WAZUH_AWS_BUCKET>/*",
"arn:aws:s3:::<WAZUH_AWS_BUCKET>"
]
}
]
}
Note
<WAZUH_AWS_BUCKET> is a placeholder. Replace it with the actual name of the bucket from which you want to retrieve logs.
Wazuh deletes the log files from the bucket only if you set remove_from_bucket to yes in the bucket configuration. This option is off by default and isn't in the sample configuration, so you need the second policy only if you turn it on.
After creating a policy, you can attach it directly to a user or to a group the user belongs to. In attaching a policy to an IAM user group, you see how to attach a policy to a group. More information on using other methods is available in the AWS documentation.
Configure Wazuh to process AWS Trusted Advisor logs
Make sure that the AWS integrations are enabled on the Wazuh dashboard, as described in Enable AWS integration on the Wazuh dashboard.
Add the following Wazuh module for AWS configuration to the
/var/ossec/etc/ossec.conffile on the Wazuh agent. Replace<WAZUH_AWS_BUCKET>with the name of the S3 bucket. Set the path value to the Firehose stream prefix you entered earlier. If the file already has a<wodle name="aws-s3">block, add only the<bucket>section to it:<wodle name="aws-s3"> <disabled>no</disabled> <interval>10m</interval> <run_on_start>yes</run_on_start> <skip_on_error>yes</skip_on_error> <bucket type="custom"> <name><WAZUH_AWS_BUCKET></name> <path>trusted-advisor</path> <aws_profile>default</aws_profile> </bucket> </wodle>
Note
This example uses the
aws_profileauthentication parameter. Check the Configure AWS credentials section to learn more about the different authentication options and how to use them.Save the changes and restart the Wazuh agent service to apply the changes:
# systemctl restart wazuh-agent