Skip to content

Instantly share code, notes, and snippets.

@rogerchi
Created August 10, 2021 16:17
Show Gist options
  • Save rogerchi/385bd627ed0928218daf422325768e61 to your computer and use it in GitHub Desktop.
Save rogerchi/385bd627ed0928218daf422325768e61 to your computer and use it in GitHub Desktop.
Create Athena View using CfnNamedQuery
// CfnDatabase from @aws-cdk/aws-glue
const db = new CfnDatabase(this, 'DB', {
catalogId: this.account,
databaseInput: {},
});
const dbName = db.ref;
const createOrRelaceViewQuery = new CfnNamedQuery(
this,
'CreateOrReplaceView',
{
database: dbName,
queryString: `CREATE OR REPLACE VIEW view_name AS
{...};
`,
description: 'Create view',
},
);
// Then pass the createOrReplaceViewQuery.attrNamedQueryId info to your lambda function to invoke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment