New to Kestra?
Use blueprints to kickstart your first workflows.
Use CloudQuery and Kestra to sync AWS resource metadata into PostgreSQL, build a cloud asset inventory, and audit S3 configurations with SQL.
Turn live AWS configuration into a queryable database. This blueprint uses CloudQuery to extract AWS resource metadata (S3 buckets in this example), loads it into PostgreSQL, and runs SQL to surface security and governance risks such as buckets that allow public access. It replaces ad-hoc console clicks and one-off CLI checks with a repeatable, version-controlled cloud asset inventory pipeline that any team can schedule, audit, and extend.
cloudquery task (io.kestra.plugin.cloudquery.CloudQueryCLI) writes an inline config.yml via inputFiles, defining an aws source (pinned to cloudquery/aws v22.4.0, tables aws_s3*) and a postgresql destination (cloudquery/postgresql v5.0.3) with write_mode: overwrite-delete-stale.cloudquery sync config.yml --log-console, pulling AWS S3 metadata and writing it into Postgres. AWS credentials, the CloudQuery API key, and the Postgres connection string are injected through env so no secrets are hardcoded.query_s3_metadata_in_postgres task (io.kestra.plugin.jdbc.postgresql.Query) connects with fetchType: FETCH and runs SQL against public.aws_s3_buckets, returning the arn and region of every bucket where block_public_acls, block_public_policy, ignore_public_acls, or restrict_public_buckets is not properly set.CloudQuery syncs data, but it has no built-in scheduler, retry semantics, or downstream branching. Kestra wraps the sync in declarative YAML, so you can attach event or schedule triggers, add automatic retries when the AWS API or Postgres hiccups, capture full execution lineage and logs, and chain the SQL analysis (and any alerting) as dependent tasks. The result is an auditable pipeline rather than a cron-driven script the sync tool cannot manage on its own.
host.docker.internal:5432.AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGIONCLOUDQUERY_API_KEYDB_PASSWORDdocker run -d --name mypostgres \
-v mypostgresdb:/var/lib/postgresql/data \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=yourPassword1234 \
-e POSTGRES_DB=postgres \
postgres:latest
query_s3_metadata_in_postgres output for any non-compliant buckets.aws_ec2*, aws_iam*, aws_ecs*, aws_glue*, or aws_dynamodb*.