Security

Tutorials

Building a serverless open source CSPM powered by CloudQuery

AWS Compliance Policy and Dashboards have been deprecated.

In this blog post, we will look at a variation of our guide on how to build an open source CSPM with CloudQuery and Grafana, only this time, you won’t need to set up any new infrastructure. We will use Neon, a serverless PostgreSQL database, a managed Grafana dashboard, and the new CloudQuery Platform.

What Is the CloudQuery Platform?

CloudQuery Platform is a great way to get started with CloudQuery and sync data from source to destination without the need to deploy your own infrastructure. You only need to select a source and destination integration and CloudQuery will take care of the rest.

With CloudQuery Platform, you can:

  • Sync data from any CloudQuery official source to any CloudQuery official destination.
  • Schedule syncs to run at regular intervals.
  • Monitor syncs and view logs in the CloudQuery Platform dashboard.
  • Use the CloudQuery Platform API to manage the syncs and connect to your other data pipelines.

Here’s what our data flow will look like:

CloudQuery serverless open source CSPM architecture

Let’s get to it.

Prerequisites

  • Sign up for a free account with Neon and create a new database. Make sure you store the connection string, you will need it later.
  • Sign up for a free account with Grafana.
  • Sign up for a CloudQuery account.

To pull data from AWS, we will use the CloudQuery AWS source integration which will require an access key and the secret associated with it. See this AWS guide if you don’t have these yet.

You will also need dbt, a data build tool, to create a few database views from CloudQuery policies. You will only need to run it once, so you can install it locally.

AWS to PostgreSQL

First, we will set up the syncs from AWS to PostgreSQL database on Neon. You will need the connection string and the AWS keys.

Next, log into the CloudQuery Platform, and start creating your first sync from the Syncs tab.

CloudQuery Platform new sync form configured to sync AWS resources to PostgreSQL

First, we need the destination database to sync to. Since the default destination is PostgreSQL, just paste the connection string into the designated input for the POSTGRESQL_CONNECTION_STRING variable.

Secrets panel with AWS credentials configured as environment variables for the sync

That’s all for the destination, let’s move on to defining the source.
From the Source Integration dropdown, select AWS. The example YAML configuration will load. Edit the tables to contain the following list of tables:

tables:
- aws_cloudwatch_alarms
- aws_cloudwatchlogs_metric_filters
- aws_ec2_network_acls
- aws_ec2_security_groups
- aws_sns_subscriptions
- aws_iam_credential_reports
- aws_iam_password_policies
- aws_iam_user_access_keys
- aws_iam_users
- aws_autoscaling_groups
- aws_cloudtrail_trail_event_selectors
- aws_cloudtrail_trails
- aws_codebuild_projects
- aws_config_configuration_recorders
- aws_apigateway_rest_api_stages
- aws_apigateway_rest_apis
- aws_apigatewayv2_api_routes
- aws_apigatewayv2_api_stages
- aws_apigatewayv2_apis
- aws_cloudfront_distributions
- aws_efs_access_points
- aws_elasticbeanstalk_environments
- aws_elbv1_load_balancers
- aws_elbv2_load_balancer_attributes
- aws_elbv2_load_balancers
- aws_iam_accounts
- aws_rds_clusters
- aws_s3_accounts

In the Secrets section, add your access key ID and the security key.

Finally, let’s schedule the sync. On the next step of the wizard, select the Daily schedule. Choose the allocated resources - 0.5 CPU and 1 GB RAM should be fine for most of the cases. Click Save and Run and the sync will start.

Creating database views

The sync should pull data from AWS directly in the Neon database. When this is done, we need to create database views the dashboards in Grafana will use.

CloudQuery has built a set of Transformations that will create these views. Download the AWS Compliance (Free) pack and extract it.
Since we will use dbt to create the views, we will need to make sure it can connect to the database. dbt looks for a file with a profile which defines how to connect to relevant databases. By default, it searches for the profiles.yml file in the local directory and falls back to ~/.dbt/. Read more about profiles in the dbt documentation.

Your profiles.yml file should look like this:

config:
send_anonymous_usage_stats: False
use_colors: True
aws_compliance: # this should match the profile name in your dbt_project.yml, see step 5.
target: postgres
outputs:
postgres:
type: postgres
host: 'your postgres host'
user: 'postgres user name'
pass: 'postgres password'
port: 5432
dbname: 'database name'
schema: public
threads: 4

With the connection configured, you can now run dbt compile and dbt run commands from the directory where you extracted the AWS Compliance transformation.

The dbt run will run all the dbt models and create views in your destination database as defined in the models.

Now you can query the views directly and export in various formats such as CSV or HTML, all with standard SQL, and of course visualize them in your favorite BI tool.

Connecting Grafana

For AWS Transformations, we offer free Grafana dashboards that you can use as a starting point.

First, you need to add the database as a data source into Grafana. Read this Grafana guide on how to do this.

Download AWS Compliance Dashboard and extract the zip file. Find the dashboard.json file in the extracted directory (in aws_compliance/grafana/postgres) and import it into your Grafana instance.

At the top of the dashboard, select the data source to be the PostgreSQL database with data synced by CloudQuery.

Now you should see a dashboard similar to this:

Grafana CSPM dashboard showing cloud security posture metrics and compliance status from CloudQuery data

Wrapping up

That’s it! You have set up a regular daily sync to a database hosted by Neon with a dashboard on Grafana Cloud that will show you your security issues.

Note that if you decide to update to a newer version of the AWS integration, you may need to run the dbt transformations again.

Want to see CloudQuery in action? Schedule a demo with our team or check out the platform documentation to learn more.

Want help getting started? Join the CloudQuery community to connect with other users and experts, or message our team directly here if you have any questions.

Try CloudQuery yourself

Self-hosted, open source, and free to start. Or schedule a demo to see the managed version.

Related posts

AWS

Security

Tutorials

Finding AWS Unrestricted Outbound Access in 2026: EC2, Lambda, and Beyond

Find EC2, Lambda, and ECS Fargate resources with unrestricted outbound access in AWS using SQL. Why egress controls still break attack chains in 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Security

Tutorials

AWS IAM Identity Center with Google Workspace as an IdP: 2026 Step-by-Step Guide

Set up AWS IAM Identity Center with Google Workspace: SAML authentication, SCIM user provisioning, and group sync with CLI or ssosync. Updated for 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

GCP

Security

Tutorials

Creating Cross-Project Service Accounts in GCP (Console + gcloud CLI)

Create a GCP service account that reads across all your projects with one credential. Covers gcloud CLI, org-level vs.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Cloud Infrastructure

Security

Tutorials

Integrate AbuseIPDB Threat Intelligence with CloudQuery

Enrich your cloud asset inventory with AbuseIPDB threat intelligence to identify public cloud IPs with known abuse reports.

Joe Karlsson

Joe Karlsson

April 20, 2026

AWS

Security

Tutorials

AWS IAM Identity Center (Formerly AWS SSO): The Complete 2026 Guide

AWS SSO is now AWS IAM Identity Center. Set it up, configure permission sets, use the AWS CLI, and audit access across accounts with SQL.

Joe Karlsson

Joe Karlsson

April 6, 2026

AWS

Security

Tutorials

Set Up AWS CLI with SSO (IAM Identity Center) — Step by Step

Set up AWS CLI v2 with IAM Identity Center in 5 minutes. Covers SSO registration scopes, sso-session config, token refresh, and multi-account profiles.

Yevgeny Pats

Yevgeny Pats

February 25, 2026

Security

Tutorials

How to Detect Public Databases Across AWS, Azure, and GCP with CloudQuery Policies

Detect publicly accessible databases across AWS RDS, Azure, and GCP Cloud SQL. Step-by-step CloudQuery Policies tutorial with copy-paste ClickHouse SQL.

Joe Karlsson

Joe Karlsson

February 12, 2026

Security

Tutorials

Audit CODEOWNERS Against Okta to Find Orphaned Code Ownership with SQL

Find CODEOWNERS entries for employees who left the company by joining Git file content with your identity provider data. No scripts, just SQL.

Joe Karlsson

Joe Karlsson

January 4, 2026

Security

Tutorials

Find Commits by Departed Employees Across All Repos with SQL

Identify code changes made by employees who left your organization by cross-referencing git commit authors against your identity provider with SQL.

Joe Karlsson

Joe Karlsson

January 4, 2026

Own your pipeline.
Own your data.