Skip to content

Commit 2fde6b5

Browse files
Merge pull request #137 from utilitywarehouse/mhughes-add-terraform-fmt-pre-commit
Add `pre-commit` config to run `terraform fmt`
2 parents ea5c0ba + 54ff285 commit 2fde6b5

28 files changed

+124
-93
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ resource "kafka_topic" "iam_revoked_v1" {
154154
name = "auth.iam-revoked-v1"
155155
replication_factor = 3
156156
partitions = 1
157-
config = {
157+
config = {
158158
# retain 100MB on each partition
159-
"retention.bytes" = "104857600"
159+
"retention.bytes" = "104857600"
160160
# keep data for 7 days
161-
"retention.ms" = "604800000"
161+
"retention.ms" = "604800000"
162162
# allow max 1 MB for a message
163163
"max.message.bytes" = "1048576"
164164
"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 = {

prod-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"

prod-aws/kafka-shared/iam.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ resource "kafka_topic" "iam_revoked_v1" {
113113
name = "auth.iam-revoked-v1"
114114
replication_factor = 3
115115
partitions = 1
116-
config = {
116+
config = {
117117
# retain 100MB on each partition
118-
"retention.bytes" = "104857600"
118+
"retention.bytes" = "104857600"
119119
# keep data for 60 days
120120
"retention.ms" = "5184000000"
121121
# allow max 1 MB for a message

0 commit comments

Comments
 (0)