Skip to content

Commit a9faaa8

Browse files
glue table
1 parent 58c3715 commit a9faaa8

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

infrastructure/terraform/components/api/README.md

Lines changed: 2 additions & 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_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2122
| <a name="input_eventpub_control_plane_bus_arn"></a> [eventpub\_control\_plane\_bus\_arn](#input\_eventpub\_control\_plane\_bus\_arn) | ARN of the EventBridge control plane bus for eventpub | `string` | `""` | no |
2223
| <a name="input_eventpub_data_plane_bus_arn"></a> [eventpub\_data\_plane\_bus\_arn](#input\_eventpub\_data\_plane\_bus\_arn) | ARN of the EventBridge data plane bus for eventpub | `string` | `""` | no |
@@ -33,6 +34,7 @@ No requirements.
3334
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used, affects things like DNS zone. Useful for named dev environments | `string` | `"main"` | no |
3435
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
3536
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
37+
| <a name="input_s3_enable_force_destroy"></a> [s3\_enable\_force\_destroy](#input\_s3\_enable\_force\_destroy) | Allow force destroy of buckets and contents via Terraform - DO NOT ENABLE IN PRODUCTION | `bool` | `false` | no |
3638
| <a name="input_shared_infra_account_id"></a> [shared\_infra\_account\_id](#input\_shared\_infra\_account\_id) | The AWS Account ID of the shared infrastructure account | `string` | `"000000000000"` | no |
3739
## Modules
3840

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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "aws_s3_bucket" "event_reporting" {
2+
bucket = "${local.csi_global}-event-reporting"
3+
force_destroy = var.s3_enable_force_destroy
4+
5+
tags = merge(local.default_tags, { "Enable-Backup" = var.enable_backups }, { "Enable-S3-Continuous-Backup" = var.enable_backups })
6+
}
7+
resource "aws_s3_bucket_ownership_controls" "eventreporting" {
8+
bucket = aws_s3_bucket.event_reporting.id
9+
10+
rule {
11+
object_ownership = "BucketOwnerPreferred"
12+
}
13+
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,19 @@ variable "core_environment" {
162162
default = "prod"
163163

164164
}
165+
166+
variable "s3_enable_force_destroy" {
167+
type = bool
168+
description = "Allow force destroy of buckets and contents via Terraform - DO NOT ENABLE IN PRODUCTION"
169+
default = false
170+
171+
validation {
172+
condition = !(var.s3_enable_force_destroy && var.parameter_bundle.environment == "prod")
173+
error_message = "s3_enable_force_destroy must not be set to true when environment is 'prod'."
174+
}
175+
}
176+
variable "enable_backups" {
177+
type = bool
178+
description = "Enable backups"
179+
default = false
180+
}

0 commit comments

Comments
 (0)