Is it possible to create an Athena view via cloudformation template. I can create the view using the Athena Dashboard but I want to do this programmatically using CF templates. Could not find any details in AWS docs so not sure if supported.
Thanks.
It is possible to create views with CloudFormation, it's just very, very, complicated. Athena views are stored in the Glue Data Catalog, like databases and tables are. In fact, Athena views are tables in Glue Data Catalog, just with slightly different contents.
See this answer for the full description how to create a view programmatically, and you'll get an idea for the complexity: Create AWS Athena view programmatically – it is possible to map that to CloudFormation, but I would not recommend it.
If you want to create databases and tables with CloudFormation, the resources are AWS::Glue::Database and AWS::Glue::Table.
In general, CloudFormation is used for deploying infrastructure in a repeatable manner. This doesn't apply much to data inside a database, which typically persists separately to other infrastructure.
For Amazon Athena, AWS CloudFormation only supports:
The closest to your requirements is Named Query, which (I think) could store a query that can create the View (eg CREATE VIEW...
).
See: AWS::Athena::NamedQuery - AWS CloudFormation
Update: @Theo points out that AWS CloudFormation also has AWS Glue functions that include:
This can apparently be used to create a view. See comments below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With