Skip to content

Commit 8d4f327

Browse files
glue table
1 parent db523a5 commit 8d4f327

5 files changed

Lines changed: 116 additions & 0 deletions

File tree

infrastructure/terraform/components/api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ No requirements.
1717
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
1818
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1919
| <a name="input_disable_gateway_execute_endpoint"></a> [disable\_gateway\_execute\_endpoint](#input\_disable\_gateway\_execute\_endpoint) | Disable the execution endpoint for the API Gateway | `bool` | `true` | no |
20+
| <a name="input_enable_backups"></a> [enable\_backups](#input\_enable\_backups) | Enable backups | `bool` | `false` | no |
2021
| <a name="input_enable_api_data_trace"></a> [enable\_api\_data\_trace](#input\_enable\_api\_data\_trace) | Enable API Gateway data trace logging | `bool` | `false` | no |
2122
| <a name="input_enable_event_cache"></a> [enable\_event\_cache](#input\_enable\_event\_cache) | Enable caching of events to an S3 bucket | `bool` | `false` | no |
2223
| <a name="input_enable_sns_delivery_logging"></a> [enable\_sns\_delivery\_logging](#input\_enable\_sns\_delivery\_logging) | Enable SNS Delivery Failure Notifications | `bool` | `false` | no |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "aws_glue_catalog_database" "supplier" {
2+
name = "${local.csi}-supplier"
3+
description = "Glue catalog database for Suppliers API"
4+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
resource "aws_glue_catalog_table" "events" {
2+
name = "events_history"
3+
database_name = aws_glue_catalog_database.supplier.name
4+
5+
table_type = "EXTERNAL_TABLE"
6+
7+
parameters = {
8+
classification = "json"
9+
}
10+
11+
storage_descriptor {
12+
location = "s3://${aws_s3_bucket.event_reporting.bucket}/events/"
13+
input_format = "org.apache.hadoop.mapred.TextInputFormat"
14+
output_format = "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
15+
16+
columns {
17+
name = "type"
18+
type = "string"
19+
}
20+
21+
columns {
22+
name = "messageid"
23+
type = "string"
24+
}
25+
26+
columns {
27+
name = "topicarn"
28+
type = "string"
29+
}
30+
31+
columns {
32+
name = "message"
33+
type = "string"
34+
}
35+
36+
columns {
37+
name = "timestamp"
38+
type = "string"
39+
}
40+
41+
columns {
42+
name = "unsubscribeurl"
43+
type = "string"
44+
}
45+
46+
columns {
47+
name = "change"
48+
type = "double"
49+
}
50+
51+
columns {
52+
name = "price"
53+
type = "double"
54+
}
55+
56+
columns {
57+
name = "ticker_symbol"
58+
type = "string"
59+
}
60+
61+
columns {
62+
name = "sector"
63+
type = "string"
64+
}
65+
66+
columns {
67+
name = "partition_0"
68+
type = "string"
69+
}
70+
71+
columns {
72+
name = "partition_1"
73+
type = "string"
74+
}
75+
76+
columns {
77+
name = "partition_2"
78+
type = "string"
79+
}
80+
81+
columns {
82+
name = "partition_3"
83+
type = "string"
84+
}
85+
}
86+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "aws_s3_bucket" "event_reporting" {
2+
bucket = "${local.csi_global}-event-reporting"
3+
4+
tags = merge(local.default_tags, { "Enable-Backup" = var.enable_backups }, { "Enable-S3-Continuous-Backup" = var.enable_backups })
5+
}
6+
resource "aws_s3_bucket_ownership_controls" "event_reporting" {
7+
bucket = aws_s3_bucket.event_reporting.id
8+
9+
rule {
10+
object_ownership = "BucketOwnerPreferred"
11+
}
12+
}
13+
resource "aws_s3_bucket_versioning" "event_reporting" {
14+
bucket = aws_s3_bucket.event_reporting.id
15+
16+
versioning_configuration {
17+
status = "Enabled"
18+
}
19+
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ variable "core_environment" {
163163

164164
}
165165

166+
variable "enable_backups" {
167+
type = bool
168+
description = "Enable backups"
169+
default = false
170+
}
171+
166172
# Event Pub/Sub cache settings
167173
variable "enable_event_cache" {
168174
type = bool

0 commit comments

Comments
 (0)