Module: lakeformation
Terraform module to deploy an instance of Amazon Lake Formation on AWS.
Usage
For a complete example, see examples/complete.
For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.
# So we can assign admin permissions to the current user
data "aws_caller_identity" "current" {}
# Use this if a service-linked role already exists, otherwise it must be created
data "aws_iam_role" "lakeformation" {
name = "AWSServiceRoleForLakeFormationDataAccess"
}
# Create a bucket to store Lake Formation data
module "s3_bucket" {
source = "cloudposse/s3-bucket/aws"
# Cloud Posse recommends pinning every module to a specific version, though usually you want to use the current one
# version = "x.x.x"
acl = "private"
versioning_enabled = false
force_destroy = true # Be careful with this!
context = module.this.context
}
# Create an Athena database linked to an S3 bucket
resource "aws_athena_database" "default" {
count = module.this.enabled ? 1 : 0
name = var.resources.database.name
bucket = module.s3_bucket.bucket_id
force_destroy = true
}
# Create a standard label resource. See [null-label](https://github.com/cloudposse/terraform-null-label/#terraform-null-label--)
module "label" {
source = "cloudposse/label/null"
# Cloud Posse recommends pinning every module to a specific version, though usually you want to use the current one
# version = "x.x.x"
namespace = "eg"
name = "example"
}
module "lakeformation" {
source = "cloudposse/lakeformation/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
s3_bucket_arn = module.s3_bucket.bucket_arn
lf_tags = {
left = ["test1", "test2"]
right = ["test3", "test4"]
}
resources = {
database = {
name = "example_db_1" # Athena database created above
tags = {
left = "test1"
}
}
}
context = module.label.this
}