1. Answers
  2. Building a GCP BigQuery Job with Pulumi

How do I build a GCP BigQuery job with Pulumi?

In this guide, we will create a BigQuery job on Google Cloud Platform (GCP) using Pulumi and TypeScript. We will define a BigQuery job that runs a query on a dataset and stores the results in a destination table. This example will show you how to manage BigQuery jobs programmatically using Pulumi.

Key Points:

  • We will use the @pulumi/gcp package to interact with GCP resources.
  • We will define a BigQuery job that runs a SQL query.
  • The job will store the query results in a specified destination table.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Define the BigQuery job
const bigqueryJob = new gcp.bigquery.Job("myBigQueryJob", {
    project: "my-gcp-project", // Replace with your GCP project ID
    location: "US", // Location of the BigQuery job
    jobId: "my-query-job", // Unique ID for the job
    query: {
        query: "SELECT name, age FROM `my-gcp-project.my_dataset.my_table` WHERE age > 30", // SQL query to run
        useLegacySql: false, // Use standard SQL
        destinationTable: {
            projectId: "my-gcp-project", // Project ID for the destination table
            datasetId: "my_dataset", // Dataset ID for the destination table
            tableId: "query_results", // Table ID for the destination table
        },
        writeDisposition: "WRITE_TRUNCATE", // Overwrite the destination table
    },
});

// Export the job ID
export const jobId = bigqueryJob.jobId;

Summary

In this example, we created a BigQuery job on GCP using Pulumi and TypeScript. The job runs a SQL query on a specified dataset and stores the results in a destination table. We used the @pulumi/gcp package to define and manage the BigQuery job. This approach allows you to automate and manage your BigQuery jobs programmatically with Pulumi.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up