Centralized patch compliance reporting
What is patch compliance?
Patch compliance is the process of ensuring all computing resources have the latest security updates and bug fixes installed according to organizational policies. A system is considered "patch compliant" when all required patches defined in your patch baseline have been successfully applied. Non-compliant systems may have missing critical security updates, potentially exposing your organization to security vulnerabilities that could be exploited by malicious actors.
In modern cloud environments spanning multiple AWS accounts and regions, decentralized patch management creates significant challenges including visibility gaps, inconsistent reporting, delayed responses to vulnerabilities, complex audit processes, and duplicated effort across teams. These challenges can lead to extended security exposure and inefficient use of resources throughout your organization.
Centralized patch compliance reporting addresses these challenges by consolidating data from all accounts and regions into a single location, providing a comprehensive view of your security posture. This approach delivers numerous benefits: a single source of truth for compliance status, real-time awareness of vulnerabilities, consistent metrics across environments, simplified auditing, trend analysis capabilities, improved resource efficiency, and the foundation for automated remediation workflows.
AWS Systems Manager provides the foundation for this centralization through Patch Manager to automate patching processes, resource data syncs to aggregate compliance data into a central S3 bucket, and analytics services like AWS Glue, Amazon Athena, and Amazon QuickSight to transform, query, and visualize the data. The solution described in this recipe leverages these components to create a comprehensive reporting system that works across your entire AWS organization, enabling more efficient operations and faster vulnerability remediation.
The resource data sync provides inventory and patch compliance metadata in the form of a JSON file. As an alternative to using Athena and QuickSight, you can use any BI or analytics tool that can pull the data from the S3 bucket.
Purpose
The purpose of this recipe is to provide sample CloudFormation templates which can be used to provision the resources required for centralized patch compliance reporting. This recipe does not cover deploying patch scan or install operations.
For more information on how to prepare for patching managed nodes, see Patching managed nodes using AWS Systems Manager and tagging.
Prerequisites
Before beginning deployment, ensure you have:
- AWS Organizations setup: A properly configured AWS Organization with a management account and member accounts.
- Managed nodes configured: Amazon Elastic Compute Cloud (EC2) instances, AWS Internet of Things (IoT) Greengrass core devices, on-premises servers, edge devices, and VMs must be Systems Manager managed nodes to perform patching operations and report patch compliance.
- Patch operations implemented: At minimum, a patch scan operation must be configured and executed at least once. Without this, there will be no compliance data to report on. For more information on different types of patching and how to implement patching, see the Patch Management Best Practices guide and the section Different types of patching.
- IAM permissions: Appropriate permissions to deploy CloudFormation templates and create the required resources in both the central reporting account and member accounts.
- Amazon QuickSight: In order to visualize patch compliance information using QuickSight, you must sign up for QuickSight.
- Amazon QuickSight Permissions to S3: You must ensure QuickSight has permissions to the S3 buckets created in Phase 1: Central account setup. More information is provided in Prerequisites to complete before deploying the CloudFormation template for QuickSight.
Considerations
Resource data sync
Currently, the AWS::SSM::ResourceDataSync resource in AWS CloudFormation does not support the DestinationDataSharing property within the S3Destination property which is required to create an inventory resource data sync which supports a simplified S3 bucket policy.
Due to this, this recipe uses a custom CloudFormation resource in the Sample CloudFormation template for organization resource data sync section to use a Lambda function to create the resource data sync.
Alternatives to using the custom resource to create the resource data sync:
- Use the standard resource data sync which is supported by CloudFormation.
- To accomplish this, you must create and use a bucket policy which grants permissions based in AWS account IDs. For more information and an example S3 bucket policy, see Before you begin.
- Update the S3 bucket policy in the Sample CloudFormation template for central reporting using Athena to use the new policy which lists out the AWS account IDs.
- Use CloudFormation StackSets to deploy the
AWS::SSM::ResourceDataSyncresource. For an example CloudFormation resource snippet, see Create a SyncToDestination resource data sync.
- Use an alternative method to create the organization resource data sync, for example, scripting via the AWS CLI or other SDKs.
Cost considerations
Implementing centralized patch compliance reporting involves several AWS services, each with associated costs:
- Amazon S3 pricing:
- Standard storage costs for inventory and patch compliance data
- Data transfer costs for syncing data from multiple accounts and regions
- Cost increases linearly with the number of managed nodes and scan frequency
- AWS Glue pricing:
- Crawler costs
- For the default configuration (daily crawler run)
- Amazon Athena pricing:
- Query costs
- Cost varies based on query complexity and frequency
- Using partitioning and filtering can significantly reduce costs
- AWS Lambda pricing:
- Minimal costs for the custom resource Lambda function
- Free tier typically covers this usage for most implementations
- Amazon QuickSight pricing (optional):
- Author licenses and Reader licenses
Architecture overview
Central reporting account
In the following diagram, the Central Reporting account is an AWS account within your AWS Organization dedicated for storing the patch and inventory metadata and querying or visualization.
It is not recommended to use the AWS Organization management account as the Central reporting account. AWS best practices for the management account recommends that you use the management account and its users and roles for tasks that must be performed only by that account. Store all of your AWS resources in other AWS accounts in the organization and keep them out of the management account.

- The Glue crawler runs once a day to crawl the S3 bucket which hosts the resource data sync provided metadata.
- The Glue crawler updates the database and tables based on the metadata in the S3 bucket.
- After the Glue crawler completes its run, an event is sent to EventBridge.
- An EventBridge rule invokes the Lambda function.
- The Lambda function removes a duplicative column for the AWS:InstanceInformation table.
備考
The
AWS:InstanceInformationtable includes a column namedresourcetype, which is also a partition key, which causes Athena queries to fail. The EventBridge rule is triggered by the Glue crawler execution, which then invokes the Lambda function to delete the column. - Athena queries the Glue database and tables based on the queries you run.
- (Optionally) You can create a QuickSight dashboard to visualize patch compliance information. Note: QuickSight is not included in the example CloudFormation template.
Member account(s)/Region(s) with managed nodes

- The CloudFormation StackSet in the delegated administrator account creates stack instances in the target AWS accounts/Regions to create the required resources.
- The stack instance creates an IAM service role, Lambda function, and custom CloudFormation resource.
- The Lambda function creates a Systems Manager resource data sync for AWS Organizations.
- The resource data sync sends inventory and patch compliance metadata to the S3 bucket specified in the central reporting account.
Process timeline
The following diagram displays the process timeline of querying patch compliance for managed nodes.

- Following a patch scan, install, or inventory metadata gathering operation, SSM agent on the managed node reports back data to Systems Manager.
- The patch and inventory metadata updates are identified by the resource data sync based on actions taken.
- The resource data sync ships the metadata to the S3 bucket specified in the central reporting account.
- You can then use Athena to query the results following the operation.
As noted in the diagram above, you can register hybrid managed nodes for patching or inventory metadata gathering and the data will flow into the same S3 bucket as EC2 instances.
Deployment steps
Deployment checklist
Below you can find a checklist for the deployment steps included in this recipe.
Central reporting account tasks
- Deploy CloudFormation stack for Athena resources
- Note S3 bucket names from stack outputs
- Configure QuickSight permissions for S3 buckets
- Deploy CloudFormation stack for QuickSight visualization
- Verify access to QuickSight analysis
Member account tasks (via StackSets)
- Deploy organization resource data sync CloudFormation StackSet
- Verify resource data syncs are created in member accounts
Phase 1: Central account setup
Sample CloudFormation template for central reporting using Athena
Below you can find details about the resources created by the CloudFormation template and their purpose.
Sample CloudFormation template for central reporting using Athena
| Resource Name | Purpose |
|---|---|
| KMS resources | |
| ManagedInstanceDataEncryptionKey | Customer managed key (CMK) to encrypt managed node metadata in the resource data sync S3 bucket. |
| ManagedInstanceDataEncryptionKeyAlias | Alias for the CMK. |
| S3 resources | |
| AthenaQueryResultsBucket | S3 bucket to store Athena query results. |
| ResourceSyncBucket | S3 bucket used to store managed node metadata provided by the resource data sync. |
| ResourceSyncBucketPolicy | S3 bucket policy for the resource data sync S3 bucket. |
| Glue resources | |
| GlueDatabase | Glue database for resource data sync metadata. |
| GlueCrawler | Glue crawler to create database and tables. |
| GlueCrawlerRole | IAM role used by Glue crawler. |
| DeleteGlueTableColumnFunctionRole | IAM role for DeleteGlueTableColumnFunction Lambda function. |
| DeleteGlueTableColumnFunction | Lambda function to remove duplicate resourcetype partition key. |
| DeleteGlueTableColumnFunctionEventRule | Amazon EventBridge rule to invoke the DeleteGlueTableColumnFunction Lambda function. |
| DeleteGlueTableColumnFunctionCloudWatchPermission | Granting EventBridge permissions to invoke the DeleteGlueTableColumnFunction Lambda function. |
| Athena resources | |
| AthenaWorkGroup | Athena workgroup for named queries. |
| AthenaQueryCompliantPatch | Example query to list managed nodes that are compliant for patching. |
| AthenaQueryNonCompliantPatch | Example query to list managed nodes that are non-compliant for patching. |
| AthenaQueryComplianceSummaryPatch | Example query to provide a compliance summary for patch for managed nodes. |
| AthenaQueryPatchSummary | Example query to provide a patch summary for managed nodes. |
| AthenaQueryInstanceList | Example query to return a list of non-terminated managed nodes. |
| AthenaQueryInstanceApplications | Example query to return a list of non-terminated managed nodes and their applications installed. |
| AthenaQuerySSMAgent | Example query to list SSM Agent versions installed on managed nodes. |
| S3 cleanup resources | |
| S3CleanupLambdaExecutionRole | IAM role to clean up S3 buckets |
| S3BucketCleanup | Lambda function to clean up S3 buckets |
| S3Cleanup | Custom resource to clean up S3 buckets |
Deploy a CloudFormation stack for Athena in the central reporting account
- Download the Sample CloudFormation template for central reporting using Athena to your local machine.
- In the central reporting account and Region, navigate to the AWS CloudFormation console.
- In left navigation pane, choose Stacks, and then choose Create stack.
- From the dropdown list, choose With new resources (standard).
- On the Create stack page, select Upload a template file, select Choose file, choose the
patch-reporting.yamlfile, and then choose Next. - On the Specify stack details page, perform the following steps:
- For Stack name, enter a descriptive name, such as
patch-reporting. - For Organization ID, enter the AWS Organization ID for your AWS Organization. For example,
o-abcde12345.
ヒントFor more information on how to retrieve the AWS Organization ID, see Viewing details of an organization from the management account.
- For Enable Glue Crawler Schedule, choose to enable or disbale scheduled execution of the Glue crawler.
- For Glue Crawler Schedule (cron), enter a cron schedule expression for the Glue crawler.
- For Enable KMS permissions for QuickSight service role, choose to enable or disable KMS permissions for the QuickSight IAM service role. Note: If you do not grant KMS permissions, you will not be able to visualize patch compliance data using QuickSight.
- Choose Next.
- For Stack name, enter a descriptive name, such as
- On the Configure stack options page, add any required tags, select I acknowledge that AWS CloudFormation might create IAM resources with custom names, and then choose Next.
- On the Review and create page, review all the information and then choose Submit to create your stack.
After the page is refreshed, the status of your stack should be CREATE_IN_PROGRESS. When the status changes to CREATE_COMPLETE, you can then deploy the QuickSight visualization.
Take note of the names of the Amazon S3 buckets for AthenaQueryResultsBucket and ResourceDataSyncBucketName which can be found in the Outputs tab of the CloudFormation stack. You will need these two values in the next section to deploy QuickSight.

Sample CloudFormation template for Amazon QuickSight visualization
Below you can find details about the resources created by the CloudFormation template and their purpose.
Sample CloudFormation template for Amazon QuickSight visualization
| Resource Name | Purpose |
|---|---|
| SSMDataSyncSource | QuickSight data source pointing to the Athena workgroup, patch-workgroup. |
| ApplicationDataSet | QuickSight dataset for the application metadata |
| ComplianceItemDataSet | QuickSight dataset for the compliance item metadata |
| ComplianceSummaryDataSet | QuickSight dataset for the compliance summary metadata |
| InstanceDetailedInformationDataSet | QuickSight dataset for the instance detailed information metadata |
| InstanceInformationDataSet | QuickSight dataset for the instance information metadata |
| TagDataSet | QuickSight dataset for the tag metadata |
| JoinedDataSet | QuickSight dataset which joins aws_instanceinformation, aws_compliancesummary, aws_tag |
| ManagedNodeAnalysis | QuickSight analysis dashboard |
The sample CloudFormation template uses the DIRECT_QUERY method which allows near real-time querying of the data source. An alternative is to use SPICE to cache the data in QuickSight. If you use SPICE, the sample template also includes example refresh schedules on lines 551-647. For more information on which mode to use, see Best practices for Amazon QuickSight SPICE and direct query mode
Prerequisites to complete before deploying the CloudFormation template for QuickSight
In order for QuickSight to access the patch compliance and inventory metadata, you must grant access to QuickSight for the S3 buckets created in Deploy a CloudFormation stack for Athena in the central reporting account: ssm-res-sync-athena-query-results-us-east-1-$AccountId and ssm-resource-sync-us-east-1-$AccountId.

For more information on how to grant access, seeI can't connect to Amazon S3.
Deploy a CloudFormation stack for QuickSight in the central reporting account
- Download the Sample CloudFormation template for Amazon QuickSight visualization to your local machine.
- In the central reporting account and Region, navigate to the AWS CloudFormation console.
- In left navigation pane, choose Stacks, and then choose Create stack.
- From the dropdown list, choose With new resources (standard).
- On the Create stack page, select Upload a template file, select Choose file, choose the
quicksight.yamlfile, and then choose Next. - On the Specify stack details page, perform the following steps:
- For Stack name, enter a descriptive name, such as
quicksight. - For QuickSightUser, enter the name of the QuickSight user to be granted permissions to the QuickSight data sources and analysis dashboard.
- For Workgroup, leave the default value
patch-workgroup. - Choose Next.
- For Stack name, enter a descriptive name, such as
- On the Configure stack options page, add any required tags, and then choose Next.
- On the Review and create page, review all the information and then choose Submit to create your stack.
After the page is refreshed, the status of your stack should be CREATE_IN_PROGRESS. When the status changes to CREATE_COMPLETE, deploy resource data syncs into the member account(s)/region(s).