Skip to content

Commit 2f52eef

Browse files
glue crawler
1 parent 34747a4 commit 2f52eef

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

infrastructure/terraform/components/api/glue_catalog_table_events.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_glue_catalog_table" "events" {
2-
name = "events_history"
2+
name = "${local.csi}-events_history"
33
database_name = aws_glue_catalog_database.supplier.name
44

55
table_type = "EXTERNAL_TABLE"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resource "aws_glue_crawler" "event_crawler" {
2+
name = "event-crawler-${aws_glue_catalog_table.events.name}"
3+
database_name = aws_glue_catalog_database.supplier.name
4+
role = aws_iam_role.glue_role.arn
5+
6+
table_prefix = ""
7+
s3_target {
8+
path = "s3://${aws_s3_bucket.event_reporting.bucket}/events/"
9+
}
10+
recrawl_policy {
11+
recrawl_behavior = "CRAWL_EVERYTHING"
12+
}
13+
14+
configuration = jsonencode({
15+
Version = 1.0
16+
CrawlerOutput = {
17+
Partitions = {
18+
AddOrUpdateBehavior = "InheritFromTable"
19+
}
20+
}
21+
})
22+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
resource "aws_iam_role" "glue_role" {
2+
name = "${local.csi}-glue-role"
3+
assume_role_policy = data.aws_iam_policy_document.glue_assume_role.json
4+
}
5+
6+
data "aws_iam_policy_document" "glue_assume_role" {
7+
statement {
8+
sid = "AllowGlueServiceAssumeRole"
9+
effect = "Allow"
10+
11+
principals {
12+
type = "Service"
13+
identifiers = ["glue.amazonaws.com"]
14+
}
15+
16+
actions = [
17+
"sts:AssumeRole",
18+
]
19+
}
20+
}
21+
22+
resource "aws_iam_policy" "glue_service_policy" {
23+
name = "${local.csi}-glue-service-policy"
24+
description = "Policy for ${local.csi} Glue Service Role"
25+
policy = data.aws_iam_policy_document.glue_service_policy.json
26+
}
27+
28+
data "aws_iam_policy_document" "glue_service_policy" {
29+
statement {
30+
sid = "AllowGlueLogging"
31+
effect = "Allow"
32+
33+
actions = [
34+
"logs:CreateLogGroup",
35+
"logs:CreateLogStream",
36+
"logs:PutLogEvents"
37+
]
38+
resources = ["arn:aws:logs:*:*:*"]
39+
}
40+
}
41+
42+
resource "aws_iam_role_policy_attachment" "gllue_attach_policy" {
43+
role = aws_iam_role.glue_role.name
44+
policy_arn = aws_iam_policy.glue_service_policy.arn
45+
}

0 commit comments

Comments
 (0)