How to create an AWS Athena data service with Pulumi

This reference shows how to use Pulumi to define an AWS Athena resource using pure code which can then be deployed to AWS and managed as infrastructure as code.

What is AWS Athena?

AWS Athena is an interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL. Find out more at AWS here.

Create an AWS Athena resource using @pulumi/aws

The @pulumi/aws library enables fine-grained control over the AWS Athena resource meaning it can be coded, deployed, and managed entirely in code.

const aws = require("@pulumi/aws");

const databaseBucket = new aws.s3.Bucket("mydatabasebucket");

const database = new aws.athena.Database("mydatabase", {
    name: "mydatabase",
    bucket: databaseBucket.bucket
});

const namedQuery = new aws.athena.NamedQuery("mynamedquery", {
    database: database.id,
    query: database.id.apply(n => `SELECT * FROM ${n} limit 10;`)
});