Skip to content

Commit 5e6ce96

Browse files
Add pre-commit config to run terraform fmt
Run the hook to format all the code and enforce this via CI to avoid regressions. This is to keep formatting consistent and not a thing to worry/think about when developing or in PRs
1 parent cbd1af4 commit 5e6ce96

28 files changed

+139
-108
lines changed

.github/workflows/pr.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Checks
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: hashicorp/[email protected]
14+
- uses: actions/[email protected]
15+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.86.0
4+
hooks:
5+
- id: terraform_fmt

CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Linting
2+
3+
Linting is handled via `pre-commit`. Follow the [install
4+
instructions](https://pre-commit.com/#install), and additionally [install
5+
Terraform](https://developer.hashicorp.com/terraform/install) then install and
6+
run the hooks:
7+
8+
``` console
9+
$ pre-commit install
10+
$ pre-commit run --all-hooks
11+
```

dev-aws/finance/debt.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "kafka_topic" "account-debt-events" {
4141
}
4242

4343
resource "kafka_topic" "debt-collection-events" {
44-
name = "debt-collection.events"
44+
name = "debt-collection.events"
4545
replication_factor = 3
4646
partitions = 3
4747
config = {

dev-aws/finance/direct-debits.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ resource "kafka_topic" "dd_run_reconciliation_events" {
1515
partitions = 10
1616
config = {
1717
"max.message.bytes" = "1048576"
18-
"retention.bytes" = "-1"
19-
"retention.ms" = "259200000" #3 days, maybe worth doing it less
20-
"cleanup.policy" = "delete"
18+
"retention.bytes" = "-1"
19+
"retention.ms" = "259200000" #3 days, maybe worth doing it less
20+
"cleanup.policy" = "delete"
2121
}
2222
}
2323

dev-aws/finance/disputes-fabricator.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "kafka_topic" "comms-eqdb-loader-events" {
1010
}
1111

1212
resource "kafka_topic" "disputes-diffs-events" {
13-
name = "disputes-diffs.events"
13+
name = "disputes-diffs.events"
1414
replication_factor = 3
1515
partitions = 10
1616
config = {

dev-aws/kafka-shared/customer-billing.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ resource "kafka_topic" "invoice_fulfillment" {
22
name = "bex.internal.bill_fulfilled"
33
replication_factor = 3
44
partitions = 10
5-
config = {
5+
config = {
66
# keep data for 7 days
7-
"retention.ms" = "604800000"
7+
"retention.ms" = "604800000"
88
# allow max 1 MB for a message
99
"max.message.bytes" = "1048576"
1010
"compression.type" = "zstd"
@@ -16,9 +16,9 @@ resource "kafka_topic" "invoice_fulfillment_deadletter" {
1616
name = "bex.internal.accountreadytobefulfilled_deadletter"
1717
replication_factor = 3
1818
partitions = 10
19-
config = {
19+
config = {
2020
# keep data for 14 days
21-
"retention.ms" = "1209600000"
21+
"retention.ms" = "1209600000"
2222
# allow max 1 MB for a message
2323
"max.message.bytes" = "1048576"
2424
"compression.type" = "zstd"

dev-aws/kafka-shared/iam.tf

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ resource "kafka_topic" "iam_cerbos_audit_v1" {
22
name = "auth.iam-cerbos-audit-v1"
33
replication_factor = 3
44
partitions = 10
5-
config = {
5+
config = {
66
# retain 100MB on each partition
7-
"retention.bytes" = "104857600"
7+
"retention.bytes" = "104857600"
88
# keep data for 2 days
9-
"retention.ms" = "172800000"
9+
"retention.ms" = "172800000"
1010
# allow max 1 MB for a message
1111
"max.message.bytes" = "1048576"
1212
"compression.type" = "zstd"
@@ -30,11 +30,11 @@ resource "kafka_topic" "iam_credentials_v1" {
3030
name = "auth-customer.iam-credentials-v1"
3131
replication_factor = 3
3232
partitions = 10
33-
config = {
33+
config = {
3434
# retain 100MB on each partition
35-
"retention.bytes" = "104857600"
35+
"retention.bytes" = "104857600"
3636
# keep data for 7 days
37-
"retention.ms" = "604800000"
37+
"retention.ms" = "604800000"
3838
# allow max 1 MB for a message
3939
"max.message.bytes" = "1048576"
4040
"compression.type" = "zstd"
@@ -64,11 +64,11 @@ resource "kafka_topic" "iam_dpd_v1" {
6464
name = "auth-customer.iam-dpd-v1"
6565
replication_factor = 3
6666
partitions = 1
67-
config = {
67+
config = {
6868
# retain 100MB on each partition
69-
"retention.bytes" = "104857600"
69+
"retention.bytes" = "104857600"
7070
# keep data for 7 days
71-
"retention.ms" = "604800000"
71+
"retention.ms" = "604800000"
7272
# allow max 1 MB for a message
7373
"max.message.bytes" = "1048576"
7474
"compression.type" = "zstd"
@@ -105,12 +105,12 @@ resource "kafka_topic" "iam_identitydb_v1" {
105105
name = "auth.iam-identitydb-v1"
106106
replication_factor = 3
107107
# MUST be 1 partition as identitydb assumes this to be true
108-
partitions = 1
109-
config = {
108+
partitions = 1
109+
config = {
110110
# retain 100MB on each partition
111-
"retention.bytes" = "104857600"
111+
"retention.bytes" = "104857600"
112112
# keep data for 30 days
113-
"retention.ms" = "2592000000"
113+
"retention.ms" = "2592000000"
114114
# allow max 5 MB for a message
115115
"max.message.bytes" = "5242880"
116116
"compression.type" = "zstd"

dev-aws/kafka-shared/kafka-ui.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ resource "kafka_acl" "kafka_ui_group" {
1717
}
1818

1919
resource "kafka_acl" "kafka_ui_cluster" {
20-
resource_name = "kafka-cluster"
21-
resource_type = "Cluster"
22-
acl_principal = "User:CN=pubsub/kafka-ui"
23-
acl_host = "*"
24-
acl_operation = "All"
25-
acl_permission_type = "Allow"
20+
resource_name = "kafka-cluster"
21+
resource_type = "Cluster"
22+
acl_principal = "User:CN=pubsub/kafka-ui"
23+
acl_host = "*"
24+
acl_operation = "All"
25+
acl_permission_type = "Allow"
2626
resource_pattern_type_filter = "Literal"
2727
}

dev-aws/kafka-shared/mirror-maker.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ resource "kafka_acl" "mirror_maker_group_access" {
1717
}
1818

1919
resource "kafka_acl" "mirror_maker_cluster_access" {
20-
resource_name = "kafka-cluster"
21-
resource_type = "Cluster"
22-
acl_principal = "User:CN=pubsub/mirror-maker"
23-
acl_host = "*"
24-
acl_operation = "All"
25-
acl_permission_type = "Allow"
20+
resource_name = "kafka-cluster"
21+
resource_type = "Cluster"
22+
acl_principal = "User:CN=pubsub/mirror-maker"
23+
acl_host = "*"
24+
acl_operation = "All"
25+
acl_permission_type = "Allow"
2626
resource_pattern_type_filter = "Literal"
2727
}

dev-aws/kafka-shared/otel.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ resource "kafka_topic" "otlp_spans" {
1919
}
2020

2121
module "otel_collector" {
22-
source = "../../modules/tls-app"
23-
produce_topics = [kafka_topic.otlp_spans.name]
22+
source = "../../modules/tls-app"
23+
produce_topics = [kafka_topic.otlp_spans.name]
2424
cert_common_name = "otel/collector"
2525
}
2626

2727
module "tempo_distributor" {
28-
source = "../../modules/tls-app"
29-
consume_topics = {(kafka_topic.otlp_spans.name): "processor-tempo"}
28+
source = "../../modules/tls-app"
29+
consume_topics = { (kafka_topic.otlp_spans.name) : "processor-tempo" }
3030
cert_common_name = "otel/tempo-distributor"
3131
}

dev-aws/kafka-shared/pubsub-examples.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ resource "kafka_topic" "pubsub_examples" {
22
name = "dev-enablement.pubsub-examples"
33
replication_factor = 3
44
partitions = 10
5-
config = {
5+
config = {
66
# retain 100MB on each partition
7-
"retention.bytes" = "104857600"
7+
"retention.bytes" = "104857600"
88
# keep data for 2 days
9-
"retention.ms" = "172800000"
9+
"retention.ms" = "172800000"
1010
# allow max 1 MB for a message
1111
"max.message.bytes" = "1048576"
1212
"compression.type" = "zstd"

exp-1-merit/kafka-shared/kafka-ui.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ resource "kafka_acl" "kafka_ui_group" {
1717
}
1818

1919
resource "kafka_acl" "kafka_ui_cluster" {
20-
resource_name = "kafka-cluster"
21-
resource_type = "Cluster"
22-
acl_principal = "User:CN=pubsub/kafka-ui"
23-
acl_host = "*"
24-
acl_operation = "All"
25-
acl_permission_type = "Allow"
20+
resource_name = "kafka-cluster"
21+
resource_type = "Cluster"
22+
acl_principal = "User:CN=pubsub/kafka-ui"
23+
acl_host = "*"
24+
acl_operation = "All"
25+
acl_permission_type = "Allow"
2626
resource_pattern_type_filter = "Literal"
2727
}

exp-1-merit/kafka-shared/pdp-audit.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ resource "kafka_topic" "iam_cerbos_audit_v1" {
55

66
config = {
77
# retain 100MB on each partition
8-
"retention.bytes" = "104857600"
8+
"retention.bytes" = "104857600"
99
# keep data for 2 days
10-
"retention.ms" = "172800000"
10+
"retention.ms" = "172800000"
1111
# allow max 1 MB for a message
1212
"max.message.bytes" = "1048576"
1313
"compression.type" = "zstd"

exp-1-merit/kafka-shared/pubsub-examples.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ resource "kafka_topic" "pubsub_examples" {
99
"retention.ms" = "172800000"
1010
# allow max 1 MB for a message
1111
"max.message.bytes" = "1048576"
12-
"compression.type" = "zstd"
13-
"cleanup.policy" = "delete"
12+
"compression.type" = "zstd"
13+
"cleanup.policy" = "delete"
1414
}
1515
}
1616

@@ -24,8 +24,8 @@ resource "kafka_acl" "example_producer_topic_access" {
2424
}
2525

2626
resource "kafka_quota" "example_producer_quota" {
27-
entity_name = "User:CN=pubsub/example-producer"
28-
entity_type = "user"
27+
entity_name = "User:CN=pubsub/example-producer"
28+
entity_type = "user"
2929
config = {
3030
# limit producing to 5 MB/s
3131
"producer_byte_rate" = "5242880"
@@ -53,8 +53,8 @@ resource "kafka_acl" "example_consume_process_individually_group_access" {
5353
}
5454

5555
resource "kafka_quota" "example_consume_process_individually_quota" {
56-
entity_name = "User:CN=pubsub/example-consume-process-individually"
57-
entity_type = "user"
56+
entity_name = "User:CN=pubsub/example-consume-process-individually"
57+
entity_type = "user"
5858
config = {
5959
# limit consuming to 5 MB/s
6060
"consumer_byte_rate" = "5242880"

exp-1-merit/pubsub-msk/kafka-ui.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ resource "kafka_acl" "kafka_ui_group" {
1717
}
1818

1919
resource "kafka_acl" "kafka_ui_cluster" {
20-
resource_name = "kafka-cluster"
21-
resource_type = "Cluster"
22-
acl_principal = "User:CN=pubsub/kafka-ui"
23-
acl_host = "*"
24-
acl_operation = "All"
25-
acl_permission_type = "Allow"
20+
resource_name = "kafka-cluster"
21+
resource_type = "Cluster"
22+
acl_principal = "User:CN=pubsub/kafka-ui"
23+
acl_host = "*"
24+
acl_operation = "All"
25+
acl_permission_type = "Allow"
2626
resource_pattern_type_filter = "Literal"
2727

2828
depends_on = [kafka_acl.tf_applier_cluster]

exp-1-merit/pubsub-msk/pubsub-examples.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ resource "kafka_topic" "pubsub_examples" {
1212
"local.retention.ms" = "3600000"
1313
# allow max 1 MB for a message
1414
"max.message.bytes" = "1048576"
15-
"compression.type" = "zstd"
16-
"cleanup.policy" = "delete"
15+
"compression.type" = "zstd"
16+
"cleanup.policy" = "delete"
1717
}
1818
}
1919

@@ -27,8 +27,8 @@ resource "kafka_acl" "example_producer_topic_access" {
2727
}
2828

2929
resource "kafka_quota" "example_producer_quota" {
30-
entity_name = "User:CN=pubsub/example-producer"
31-
entity_type = "user"
30+
entity_name = "User:CN=pubsub/example-producer"
31+
entity_type = "user"
3232
config = {
3333
# limit producing to 5 MB/s
3434
"producer_byte_rate" = "5242880"
@@ -56,8 +56,8 @@ resource "kafka_acl" "example_consume_process_individually_group_access" {
5656
}
5757

5858
resource "kafka_quota" "example_consume_process_individually_quota" {
59-
entity_name = "User:CN=pubsub/example-consume-process-individually"
60-
entity_type = "user"
59+
entity_name = "User:CN=pubsub/example-consume-process-individually"
60+
entity_type = "user"
6161
config = {
6262
# limit consuming to 5 MB/s
6363
"consumer_byte_rate" = "5242880"

exp-1-merit/pubsub-msk/tf-applier.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ resource "kafka_acl" "tf_applier_group" {
1717
}
1818

1919
resource "kafka_acl" "tf_applier_cluster" {
20-
resource_name = "kafka-cluster"
21-
resource_type = "Cluster"
22-
acl_principal = "User:CN=pubsub/tf-applier"
23-
acl_host = "*"
24-
acl_operation = "All"
25-
acl_permission_type = "Allow"
20+
resource_name = "kafka-cluster"
21+
resource_type = "Cluster"
22+
acl_principal = "User:CN=pubsub/tf-applier"
23+
acl_host = "*"
24+
acl_operation = "All"
25+
acl_permission_type = "Allow"
2626
resource_pattern_type_filter = "Literal"
2727
}

modules/tls-app/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ resource "kafka_acl" "producer_acl" {
3434
resource "kafka_quota" "quota" {
3535
entity_name = "User:CN=${var.cert_common_name}"
3636
entity_type = "user"
37-
config = {
37+
config = {
3838
"consumer_byte_rate" = tostring(var.consumer_byte_rate)
3939
"producer_byte_rate" = tostring(var.producer_byte_rate)
4040
"request_percentage" = tostring(var.request_percentage)

modules/tls-app/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ variable "request_percentage" {
4949
type = number
5050
description = "The percentage of requests a specified entity is allowed to make."
5151
# Allow 100% of CPU. More on this here: https://docs.confluent.io/kafka/design/quotas.html#request-rate-quotas
52-
default = 100
52+
default = 100
5353

5454
validation {
5555
condition = var.request_percentage >= 0 && var.request_percentage <= 100

prod-aws/finance/complaints-fabricator.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ resource "kafka_topic" "complaints-eqdb-loader-events" {
1515
partitions = 10
1616
config = {
1717
"retention.bytes" = "-1"
18-
"retention.ms" = "-1"
18+
"retention.ms" = "-1"
1919
"cleanup.policy" = "delete"
2020
}
2121
}

prod-aws/finance/debt.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "kafka_topic" "account-debt-events" {
4141
}
4242

4343
resource "kafka_topic" "debt-collection-events" {
44-
name = "debt-collection.events"
44+
name = "debt-collection.events"
4545
replication_factor = 3
4646
partitions = 10
4747
config = {

prod-aws/finance/disputes-fabricator.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "kafka_topic" "comms-eqdb-loader-events" {
1010
}
1111

1212
resource "kafka_topic" "disputes-diffs-v1-events" {
13-
name = "disputes-diffs.v1-events"
13+
name = "disputes-diffs.v1-events"
1414
replication_factor = 3
1515
partitions = 10
1616
config = {

0 commit comments

Comments
 (0)