CloudWiki
Resource

Athena

Amazon Web Services
Analytics
Amazon Athena is a serverless, interactive query service that allows you to analyze data directly in Amazon Simple Storage Service (S3) using standard SQL. It provides a fast, easy, and cost-effective way to analyze large amounts of data stored in S3, making it ideal for a variety of use cases such as data lake analytics, log analysis, and ad-hoc querying. With Amazon Athena, you don't need to manage any infrastructure, you pay only for the queries that you run, and you can start analyzing your data within minutes.
Terraform Name
terraform
aws_athena_named_query
Athena
attributes:

The following arguments are supported:

  • name - (Required) Plain language name for the query. Maximum length of 128.
  • workgroup - (Optional) Workgroup to which the query belongs. Defaults to primary
  • database - (Required) Database to which the query belongs.
  • query - (Required) Text of the query itself. In other words, all query statements. Maximum length of 262144.
  • description - (Optional) Brief explanation of the query. Maximum length of 1024.

Associating resources with a
Athena
Resources do not "belong" to a
Athena
Rather, one or more Security Groups are associated to a resource.
Create
Athena
via Terraform:
The following HCL creates an Athena Named Query resource
Syntax:

resource "aws_s3_bucket" "hoge" {
 bucket = "tf-test"
}

resource "aws_kms_key" "test" {
 deletion_window_in_days = 7
 description             = "Athena KMS Key"
}

resource "aws_athena_workgroup" "test" {
 name = "example"

 configuration {
   result_configuration {
     encryption_configuration {
       encryption_option = "SSE_KMS"
       kms_key_arn       = aws_kms_key.test.arn
     }
   }
 }
}

resource "aws_athena_database" "hoge" {
 name   = "users"
 bucket = aws_s3_bucket.hoge.id
}

resource "aws_athena_named_query" "foo" {
 name      = "bar"
 workgroup = aws_athena_workgroup.test.id
 database  = aws_athena_database.hoge.name
 query     = "SELECT * FROM ${aws_athena_database.hoge.name} limit 10;"
}

Create
Athena
via CLI:
Parametres:

create-named-query
--name <value>
[--description <value>]
--database <value>
--query-string <value>
[--client-request-token <value>]
[--work-group <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]

Example:

aws athena create-named-query \
   --name "SEA to JFK delayed flights Jan 2016" \
   --description "Both arrival and departure delayed more than 10 minutes." \
   --database sampledb \
   --query-string "SELECT flightdate, carrier, flightnum, origin, dest, depdelayminutes, arrdelayminutes FROM sampledb.flights_parquet WHERE yr = 2016 AND month = 1 AND origin = '\"SEA\"' AND dest = '\"JFK\"' AND depdelayminutes > 10 AND arrdelayminutes > 10" \
   --work-group AthenaAdmin

aws cost
Costs
Athena charges for the amount of data scanned by each query, rounded up to the nearest MB, with a 10 MB data scanning minimum per query. You are also charged for the amount of storage used by your query results, with additional fees for data transfer and Inter-Region Data Transfer. The cost of using Athena can vary based on the number of queries run, the complexity of queries, and the amount of data scanned and stored.
Direct Cost

--

Indirect Cost
No items found.
Best Practices for
Athena

Categorized by Availability, Security & Compliance and Cost

Low
Access allowed from VPN
No items found.
Low
Auto Scaling Group not in use
No items found.
Medium
Connections towards DynamoDB should be via VPC endpoints
No items found.
Medium
Container in CrashLoopBackOff state
No items found.
Low
EC2 with GPU capabilities
No items found.
Medium
EC2 with high privileged policies
No items found.
Medium
ECS cluster delete alarm
No items found.
Critical
ECS task with Admin access (*:*)
Medium
ECS task with high privileged policies
No items found.
Critical
EKS cluster delete alarm
No items found.
Medium
ElastiCache cluster delete alarm
No items found.
Medium
Ensure Container liveness probe is configured
No items found.
Medium
Ensure ECS task definition has memory limit
No items found.
Critical
Ensure EMR cluster master nodes are not publicly accessible
No items found.
More from
Amazon Web Services