-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Feature AWS Athena Terraform module 🚀 #1
Changes from all commits
8993605
ddd94e5
51c5173
10b9ba9
0b73b08
ccec591
8a822fe
f07126f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
## examples/basic | ||
## Basic Example to create AWS Athena | ||
|
||
An example which shows _basic_ usage of the module. | ||
This folder contains a basic example of how to use the terraform athena module to create an Athena workgroup, database. The table is based on a sample CSV file stored in an S3 bucket. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
## Inputs | ||
|
||
- `name` : The name of the Athena workgroup. Required. | ||
- `environment` : The environment of the Athena module created. Optional | ||
- `label_order` : The label order of the module, used to create te name of Athena workgroup. e.g. ["name", "environment"] or ["name"] Optional | ||
- `enabled` : The Bool value that refers the creation of AWS Athena resources. Optional | ||
- `workgroup_force_destroy` : The option to delete the workgroup and its contents even if the workgroup contains any named queries. Optional | ||
- `bucket_force_destroy` : A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. Optional | ||
- `s3_output_path` : The S3 bucket path used to store query results. Optional | ||
- `databases` : Map of Athena databases and related configuration. Required | ||
|
||
## Outputs | ||
|
||
- `athena_workgroup_id` : The ID of the Athena workgroup. | ||
- `athena_databases` : The ID of the Athena database. | ||
- `athena_s3_bucket_id` : The ID of the S3 bucket. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# Managed By : CloudDrove | ||
# Copyright @ CloudDrove. All Right Reserved. | ||
|
||
##------------------------------------------------------------------------------ | ||
## Provider | ||
##------------------------------------------------------------------------------ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
## AWS Athena Module | ||
##------------------------------------------------------------------------------ | ||
|
||
module "athena" { | ||
source = "../../" | ||
name = "athena" | ||
environment = "test" | ||
label_order = ["name", "environment"] | ||
enabled = true | ||
workgroup_force_destroy = true | ||
|
||
# S3 Bucket Configuration | ||
bucket_force_destroy = true | ||
s3_output_path = "accessLogs/queryresults/" # The S3 bucket path used to store query results | ||
bucket_versioning = true | ||
|
||
# Database for Athena | ||
databases = { | ||
database1 = { | ||
force_destroy = true | ||
properties = { | ||
custom_prop_1 = "example" | ||
} | ||
encryption_configuration = { | ||
encryption_option = "SSE_KMS" | ||
} | ||
} | ||
} | ||
} | ||
Comment on lines
+16
to
+41
Check warning Code scanning / defsec S3 Data should be versioned Warning
Bucket does not have versioning enabled
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Data version will have additional cost in s3 so didn't used it in example. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Outputs | ||
# ------------------------------------------------------------------------------ | ||
|
||
# Managed By : CloudDrove | ||
# Copyright @ CloudDrove. All Right Reserved. | ||
|
||
##------------------------------------------------------------------------------ | ||
## Outputs | ||
##------------------------------------------------------------------------------ | ||
|
||
output "athena_s3_bucket_id" { | ||
description = "ID of S3 bucket used by Athena." | ||
value = module.athena.bucket_id | ||
} | ||
|
||
output "athena_kms_key_arn" { | ||
description = "ARN of KMS key used by Athena." | ||
value = module.athena.kms_key_arn | ||
} | ||
|
||
output "athena_workgroup_id" { | ||
description = "ID of newly created Athena workgroup." | ||
value = module.athena.workgroup_id | ||
} | ||
|
||
output "athena_databases" { | ||
description = "List of newly created Athena databases." | ||
value = module.athena.databases | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
## examples/complete | ||
## Complete Example to create AWS Athena | ||
|
||
An example which shows _complete_ usage of the module. | ||
This folder contains a basic example of how to use the terraform athena module to create a S3 bucket, Athena workgroup, database, queries. The table is based on a sample CSV file stored in an S3 bucket. | ||
|
||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
## Inputs | ||
|
||
- `name` : The name of the Athena workgroup. Required. | ||
- `environment` : The environment of the Athena module created. Optional | ||
- `label_order` : The label order of the module, used to create te name of Athena workgroup. e.g. ["name", "environment"] or ["name"] Optional | ||
- `enabled` : The Bool value that refers the creation of AWS Athena resources. Optional | ||
- `workgroup_force_destroy` : The option to delete the workgroup and its contents even if the workgroup contains any named queries. Optional | ||
- `bucket_force_destroy` : A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. Optional | ||
- `s3_output_path` : The S3 bucket path used to store query results. Optional | ||
- `databases` : Map of Athena databases and related configuration. Required | ||
- `data_catalogs` : Map of Athena data catalogs and related configuration. Optional | ||
- `named_queries` : Map of Athena named queries and related configuration. Optional | ||
|
||
## Outputs | ||
|
||
- `athena_workgroup_id` : The ID of the Athena workgroup. | ||
- `athena_databases` : The ID of the Athena database. | ||
- `athena_s3_bucket_id` : The ID of the S3 bucket. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
# Managed By : CloudDrove | ||
# Copyright @ CloudDrove. All Right Reserved. | ||
|
||
##------------------------------------------------------------------------------ | ||
## Provider | ||
##------------------------------------------------------------------------------ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
## Local | ||
##------------------------------------------------------------------------------ | ||
locals { | ||
name = "athena" | ||
environment = "test" | ||
label_order = ["name", "environment"] | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
## AWS S3 | ||
##------------------------------------------------------------------------------ | ||
module "s3_bucket" { | ||
source = "clouddrove/s3/aws" | ||
version = "1.3.0" | ||
name = format("%s-bucket-test", local.name) | ||
versioning = true | ||
acl = "private" | ||
force_destroy = true | ||
} | ||
Comment on lines
+24
to
+31
Check warning Code scanning / defsec S3 Bucket does not have logging enabled. Warning
Bucket does not have logging enabled
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Data version in the Athena's s3 bucket is not required because we are not using s3 for logging.
Comment on lines
+24
to
+31
Check warning Code scanning / defsec S3 Data should be versioned Warning
Bucket does not have versioning enabled
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Data version in the Athena's s3 bucket is not required because we are not using s3 for logging. |
||
|
||
##------------------------------------------------------------------------------ | ||
## AWS Athena Module | ||
##------------------------------------------------------------------------------ | ||
|
||
module "athena" { | ||
source = "../../" | ||
name = local.name | ||
environment = local.environment | ||
label_order = local.label_order | ||
enabled = true | ||
workgroup_force_destroy = true | ||
|
||
# S3 Bucket Configuration | ||
create_s3_bucket = false | ||
athena_s3_bucket_id = module.s3_bucket.id | ||
s3_output_path = "outputs/" # The S3 bucket path used to store query results | ||
bucket_versioning = true | ||
|
||
# Database for Athena | ||
databases = { | ||
database1 = { | ||
force_destroy = true | ||
properties = { | ||
custom_prop_1 = "example" | ||
} | ||
encryption_configuration = { | ||
encryption_option = "SSE_KMS" | ||
} | ||
} | ||
} | ||
|
||
# Data catalog to test terraform | ||
data_catalogs = { | ||
glue1 = { | ||
description = "This is an example to test Terraform" | ||
type = "GLUE" | ||
parameters = { | ||
catalog-id : "xxxxxxxxxxxx" # The catalog_id is the account ID of the AWS account to which the AWS Glue catalog belongs. | ||
} | ||
} | ||
} | ||
|
||
# Named Queries to test terarform | ||
named_queries = { | ||
query1 = { | ||
database = "database1" | ||
description = "This is an example query to test Terraform" | ||
query = "SELECT * FROM %s limit 10;" | ||
} | ||
} | ||
} |
This file was deleted.
Check warning
Code scanning / defsec
S3 Bucket does not have logging enabled. Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bucket Logging in the Athena's s3 bucket is not required because we are not using s3 for logging.