CloudQuery News

Introducing the New Terraform Cloud Source Integration for CloudQuery

Jonathan Sarig

Jonathan Sarig

Terraform Cloud is a hosted service for Terraform, an open-source tool that helps teams set up and manage infrastructure using code (IaC). It provides a central platform for automating deployments and makes it easier for teams to work together on infrastructure changes. With features like state management, running tasks remotely, and integrations with tools like GitHub, it simplifies the process of keeping infrastructure up to date.
Today, we're excited to announce the release of the CloudQuery Terraform Cloud Source Integration. This integration lets you extract valuable information from your Terraform Cloud setup and load it into any supported CloudQuery destination. It enables powerful SQL-based querying and analysis of your infrastructure management data.

What Can You Do with the Terraform Cloud Integration? #

Our Terraform Cloud Integration integrates directly with the Terraform Cloud API to retrieve data from your organizations, projects, teams, and workspaces. This integration enables you to analyze and manage Terraform resources using SQL queries.
With this release of the CloudQuery Terraform Cloud Source Integration, you can sync and query data about your:

Getting Started with the CloudQuery Terraform Cloud Integration #

To start using the Terraform Cloud integration, you'll need to:
  1. Get Your API Token First, generate a Terraform API token in your Terraform Cloud user settings. You’ll need this token to authenticate with the Terraform Cloud API.
  2. Install CloudQuery CLI If you haven’t already, download and install the CloudQuery CLI from our download page.
  3. Set Up the Sync Configuration Create a CloudQuery configuration file by running:
cloudquery init --source terraform-cloud --destination postgresql
This command will create a terraform-cloud_to_postgresql.yaml file in your current directory.
  1. Set The Environment Variables • Set ${TERRAFORM_CLOUD_TOKEN} as an environment variable with export TERRAFORM_CLOUD_TOKEN='YOUR_TERRAFORM_CLOUD_TOKEN • Set ${POSTGRESQL_CONNECTION_STRING} as an environment variable with export POSTGRESQL_CONNECTION_STRING='YOUR_POSTGRESQL_CONNECTION_STRING
  2. Sync With CloudQuery Log in with:
cloudquery login
Then run:
cloudquery sync terraform-cloud_to_postgresql.yaml
For more details, check out the Terraform Cloud Source Integration documentation.

Use cases #

Security and Compliance #

List all organizations in Terraform that have two-factor authentication enabled:
SELECT
    name,
    two_factor_conformant
FROM
    tfcloud_organizations
WHERE
    two_factor_conformant != 'f';
Show workspaces in Terraform with failed policy checks
SELECT name, policy_check_failures
FROM tfcloud_workspaces
WHERE policy_check_failures > 0;
List all organizations in Terraform with workspaces that have failed runs and show the total number of failures per organization
SELECT
    o.name AS organization_name,
    COUNT(w.id) AS workspace_count,
    SUM(w.run_failures) AS total_run_failures
FROM
    tfcloud_organizations o
JOIN
    tfcloud_workspaces w
ON
    o.name = w.organization->>'Name'
WHERE
    w.run_failures > 0
GROUP BY
    o.name
ORDER BY
    total_run_failures DESC;

Cost Management #

Find Terraform workspaces with high costs
SELECT
    name,
    cost_estimate
FROM
    tfcloud_workspaces;
List all Terraform organizations with cost estimation disabled
SELECT
    name
FROM
    tfcloud_organizations
WHERE
    cost_estimation_enabled = 'f';
Ready to learn more about your Terraform Cloud Infrastructure? Try CloudQuery locally with our quick start guide. Got feedback or suggestions?: Join the CloudQuery Community to connect with other users and experts.
Jonathan Sarig

Written by Jonathan Sarig

Jonathan is a software engineer at CloudQuery with a particular interest in machine learning. He primarily works in golang but also has experience in (and a passion for) Rust.

Turn cloud chaos into clarity

Find out how CloudQuery can help you get clarity from a chaotic cloud environment with a personalized conversation and demo.

Join our mailing list

Subscribe to our newsletter to make sure you don't miss any updates.

Legal

© 2024 CloudQuery, Inc. All rights reserved.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve. You can always opt out later via the link in the footer.