AWS Cloud Operations & Migrations Blog
AWS CloudFormation Feature Updates: Support for Amazon Athena and Coverage Updates for Amazon S3, Amazon RDS, Amazon Kinesis and Amazon CloudWatch
As one of the most widely-used services in AWS, CloudFormation continues to expand its feature set by including adding support for Amazon Athena, two new features to protect stacks and control rollback processes, plus several new coverage updates.
CloudFormation now supports the creation of an Amazon Athena named query as a resource. Amazon Athena is a query service that makes it easy to analyze data directly from files stored in S3 using standard SQL statements. Named queries can then be executed manually from the AWS Management Console, CLI or programmatically using API calls.
You can now create a standard set of named queries using CloudFormation templates. To try it out, you can use some of the sample data provided by Athena, as covered in Jeff Barr’s blog post here.
After you’ve verified that your query properly runs on Athena, use CloudFormation to create a query using the AWS::Athena::NamedQuery resource type:
--- #=============================================================================== # Template: athena-named-query.yaml # # Purpose: Creates an Athena Named Query via AWS CloudFormation, using the # default data set provided by Athena. #=============================================================================== AWSTemplateFormatVersion: "2010-09-09" Description: | Uses the default data set in Amazon Athena, with a sample elb logs table, to demonstrate how to create a named query via a CloudFormation template. This query checks for HTTP response codes and counts each code's occurrence Resources: AthenaNamedQuery: Type: AWS::Athena::NamedQuery Properties: Database: "default" Description: "Select and count HTTP response codes" Name: "HTTPResponseCodeCount" QueryString: > SELECT backend_response_code, count(*) FROM default."elb_logs" GROUP BY backend_response_code;
This YAML template above executes using a Create Stack call in under a minute. Then, go to the Athena console and find the query you created using CloudFormation under the Saved Queries menu:
Note our new query, HTTPResponseCodeCount, its description, and the first portion of the SQL query shows in our list, which is alphabetically sorted by name (it is the fourth item on the preceding image). Choose the name of your new query, and then choose the Run Query button to execute it:
The Results pane shows that most pages return a HTTP 200 response code, which is good (OK). You can inspect the other error codes, like 404 (Not Found), 302 (Redirect) or 500 (Server Error).
Beyond the new Athena support, two new features have been released within the last few weeks:
- Stack termination protection prevents a stack from being accidentally deleted. It’s a property that can be enabled on new or existing stacks, and it provides yet another level of protection for stacks and their resources. This setting is disabled by default, so you have to explicitly enable it when you create new stacks. For existing, non-nested stacks, you can change termination protection using the console or CLI.
- Rollback triggers allow you to have CloudFormation monitor the state of your application while the stack is being created or updated, and to roll back that create or update operation if the application triggers any alarms you have configured. Chuck Meyer’s blog post here demonstrates the use of rollback triggers.
CloudFormation has also introduced the following resource coverage updates:
- Amazon Simple Storage Service (S3)
- Configure the transfer acceleration state.
- Amazon Relational Database Service (RDS)
- Update engine property from Oracle-SE or Oracle SE1 to Oracle SE2 without the database instance being replaced.
- AWS Elastic Load Balancing (ELB)
- AWS Elastic Beanstalk
- Amazon Elastic Compute Cloud (EC2)
- Specify resource tags for a Network Address Translation (NAT) gateway.
- Amazon Kinesis Firehose
- Specify the stream type, as well as stream and role ARNs for a Kinesis stream used as a source for a delivery stream.
- Amazon CloudWatch
- Support new properties for input transformation of events, as well as setting Amazon ECS tasks and Kinesis stream targets.
Visit our product and documentation pages for more information, as well as our list of supported AWS resources.
About the Author
Luis Colon is a Senior Developer Advocate for the AWS CloudFormation team. He works with customers and internal development teams to focus on and improve the developer experience for CloudFormation users. In his spare time, he mixes progressive trance music.