Skip to content

Commit

Permalink
Add pre-commit config to run terraform fmt
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthewhughes-uw committed Feb 8, 2024
1 parent bfdfc80 commit 6aedd9a
Show file tree
Hide file tree
Showing 38 changed files with 183 additions and 153 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Checks
on:
push:
branches:
- main
pull_request:

jobs
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: pre-commit/action@v3
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
hooks:
- id: terraform_fmt
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Linting

Linting is handled via `pre-commit`. Follow the [install
instructions](https://pre-commit.com/#install), and additionally [install
Terraform](https://developer.hashicorp.com/terraform/install) then install and
run the hooks:

``` console
$ pre-commit install
$ pre-commit run --all-hooks
```
2 changes: 1 addition & 1 deletion dev-aws/finance/debt.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ resource "kafka_topic" "account-debt-events" {
}

resource "kafka_topic" "debt-collection-events" {
name = "debt-collection.events"
name = "debt-collection.events"
replication_factor = 3
partitions = 3
config = {
Expand Down
6 changes: 3 additions & 3 deletions dev-aws/finance/direct-debits.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ resource "kafka_topic" "dd_run_reconciliation_events" {
partitions = 10
config = {
"max.message.bytes" = "1048576"
"retention.bytes" = "-1"
"retention.ms" = "259200000" #3 days, maybe worth doing it less
"cleanup.policy" = "delete"
"retention.bytes" = "-1"
"retention.ms" = "259200000" #3 days, maybe worth doing it less
"cleanup.policy" = "delete"
}
}

Expand Down
2 changes: 1 addition & 1 deletion dev-aws/finance/disputes-fabricator.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "kafka_topic" "comms-eqdb-loader-events" {
}

resource "kafka_topic" "disputes-diffs-events" {
name = "disputes-diffs.events"
name = "disputes-diffs.events"
replication_factor = 3
partitions = 10
config = {
Expand Down
8 changes: 4 additions & 4 deletions dev-aws/kafka-shared/customer-billing.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ resource "kafka_topic" "invoice_fulfillment" {
name = "bex.internal.bill_fulfilled"
replication_factor = 3
partitions = 10
config = {
config = {
# keep data for 7 days
"retention.ms" = "604800000"
"retention.ms" = "604800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
Expand All @@ -16,9 +16,9 @@ resource "kafka_topic" "invoice_fulfillment_deadletter" {
name = "bex.internal.accountreadytobefulfilled_deadletter"
replication_factor = 3
partitions = 10
config = {
config = {
# keep data for 14 days
"retention.ms" = "1209600000"
"retention.ms" = "1209600000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
Expand Down
4 changes: 2 additions & 2 deletions dev-aws/kafka-shared/iam_cerbos-audit.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ resource "kafka_topic" "iam_cerbos_audit_v1" {
"retention.ms" = "172800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
}
}

Expand Down
2 changes: 1 addition & 1 deletion dev-aws/kafka-shared/iam_identitydb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "kafka_topic" "iam_identitydb_v1" {
name = "auth.iam-identitydb-v1"
replication_factor = 3
# MUST be 1 partition as identitydb assumes this to be true
partitions = 1
partitions = 1
config = {
# retain 100MB on each partition
"retention.bytes" = "104857600"
Expand Down
12 changes: 6 additions & 6 deletions dev-aws/kafka-shared/kafka-ui.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "kafka_ui_group" {
}

resource "kafka_acl" "kafka_ui_cluster" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
12 changes: 6 additions & 6 deletions dev-aws/kafka-shared/mirror-maker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "mirror_maker_group_access" {
}

resource "kafka_acl" "mirror_maker_cluster_access" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/mirror-maker"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/mirror-maker"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
8 changes: 4 additions & 4 deletions dev-aws/kafka-shared/otel.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ resource "kafka_acl" "otel_collector_topic_otlp_spans_access" {
}

resource "kafka_quota" "otel_collector_producer_quota" {
entity_name = "User:CN=otel/collector"
entity_type = "user"
entity_name = "User:CN=otel/collector"
entity_type = "user"
config = {
# limit producing to 5 MB/s
"producer_byte_rate" = "5242880"
Expand Down Expand Up @@ -57,8 +57,8 @@ resource "kafka_acl" "tempo_distributor_group_processor_tempo_access" {
}

resource "kafka_quota" "tempo_distributor_consumer_quota" {
entity_name = "User:CN=otel/tempo-distributor"
entity_type = "user"
entity_name = "User:CN=otel/tempo-distributor"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down
6 changes: 3 additions & 3 deletions dev-aws/kafka-shared/pubsub-examples.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ resource "kafka_topic" "pubsub_examples" {
name = "dev-enablement.pubsub-examples"
replication_factor = 3
partitions = 10
config = {
config = {
# retain 100MB on each partition
"retention.bytes" = "104857600"
"retention.bytes" = "104857600"
# keep data for 2 days
"retention.ms" = "172800000"
"retention.ms" = "172800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
Expand Down
16 changes: 8 additions & 8 deletions dev-merit/kafka-shared/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ resource "kafka_topic" "iam_cerbos_audit_v1" {
"retention.ms" = "172800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
}
}

Expand All @@ -24,8 +24,8 @@ resource "kafka_acl" "iam_cerbos_audit_v1_access" {
}

resource "kafka_quota" "iam_cerbos_audit_v1_quota" {
entity_name = "User:CN=auth/policy-decision-point"
entity_type = "user"
entity_name = "User:CN=auth/policy-decision-point"
entity_type = "user"
config = {
# limit producing to 5 MB/s
"producer_byte_rate" = "5242880"
Expand Down Expand Up @@ -53,8 +53,8 @@ resource "kafka_acl" "indexer_iam_cerbos_audit_v1_group_access" {
}

resource "kafka_quota" "indexer_iam_cerbos_audit_v1_quota" {
entity_name = "User:CN=auth/iam-cerbos-audit-v1-indexer"
entity_type = "user"
entity_name = "User:CN=auth/iam-cerbos-audit-v1-indexer"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down Expand Up @@ -82,8 +82,8 @@ resource "kafka_acl" "exporter_iam_cerbos_audit_v1_group_access" {
}

resource "kafka_quota" "exporter_iam_cerbos_audit_v1_quota" {
entity_name = "User:CN=auth/iam-cerbos-audit-v1-exporter"
entity_type = "user"
entity_name = "User:CN=auth/iam-cerbos-audit-v1-exporter"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down
12 changes: 6 additions & 6 deletions dev-merit/kafka-shared/kafka-ui.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "kafka_ui_group" {
}

resource "kafka_acl" "kafka_ui_cluster" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
12 changes: 6 additions & 6 deletions dev-merit/kafka-shared/mirror-maker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "mirror_maker_group_access" {
}

resource "kafka_acl" "mirror_maker_cluster_access" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/mirror-maker"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/mirror-maker"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
8 changes: 4 additions & 4 deletions dev-merit/kafka-shared/otel.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ resource "kafka_acl" "otel_collector_topic_otlp_spans_access" {
}

resource "kafka_quota" "otel_collector_producer_quota" {
entity_name = "User:CN=otel/collector"
entity_type = "user"
entity_name = "User:CN=otel/collector"
entity_type = "user"
config = {
# limit producing to 5 MB/s
"producer_byte_rate" = "5242880"
Expand Down Expand Up @@ -57,8 +57,8 @@ resource "kafka_acl" "tempo_distributor_group_processor_tempo_access" {
}

resource "kafka_quota" "tempo_distributor_consumer_quota" {
entity_name = "User:CN=otel/tempo-distributor"
entity_type = "user"
entity_name = "User:CN=otel/tempo-distributor"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down
20 changes: 10 additions & 10 deletions dev-merit/kafka-shared/pubsub-examples.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ resource "kafka_topic" "pubsub_examples" {
"retention.ms" = "172800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
}
}

Expand All @@ -24,8 +24,8 @@ resource "kafka_acl" "example_producer_topic_access" {
}

resource "kafka_quota" "example_producer_quota" {
entity_name = "User:CN=dev-enablement/example-producer"
entity_type = "user"
entity_name = "User:CN=dev-enablement/example-producer"
entity_type = "user"
config = {
# limit producing to 5 MB/s
"producer_byte_rate" = "5242880"
Expand Down Expand Up @@ -54,8 +54,8 @@ resource "kafka_acl" "example_consume_process_individually_group_access" {
}

resource "kafka_quota" "example_consume_process_individually_quota" {
entity_name = "User:CN=dev-enablement/example-consume-process-individually"
entity_type = "user"
entity_name = "User:CN=dev-enablement/example-consume-process-individually"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down Expand Up @@ -84,8 +84,8 @@ resource "kafka_acl" "example_consume_process_batch_group_access" {
}

resource "kafka_quota" "example_consume_process_batch_quota" {
entity_name = "User:CN=dev-enablement/example-consume-process-batch"
entity_type = "user"
entity_name = "User:CN=dev-enablement/example-consume-process-batch"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down Expand Up @@ -114,8 +114,8 @@ resource "kafka_acl" "pubsub_es_topic_indexer_group_access" {
}

resource "kafka_quota" "pubsub_es_topic_indexer_quota" {
entity_name = "User:CN=dev-enablement/es-topic-indexer"
entity_type = "user"
entity_name = "User:CN=dev-enablement/es-topic-indexer"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down
12 changes: 6 additions & 6 deletions exp-1-merit/kafka-shared/kafka-ui.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "kafka_ui_group" {
}

resource "kafka_acl" "kafka_ui_cluster" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/kafka-ui"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
12 changes: 6 additions & 6 deletions exp-1-merit/kafka-shared/pubsub-examples.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ resource "kafka_topic" "pubsub_examples" {
"retention.ms" = "172800000"
# allow max 1 MB for a message
"max.message.bytes" = "1048576"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
"compression.type" = "zstd"
"cleanup.policy" = "delete"
}
}

Expand All @@ -24,8 +24,8 @@ resource "kafka_acl" "example_producer_topic_access" {
}

resource "kafka_quota" "example_producer_quota" {
entity_name = "User:CN=pubsub/example-producer"
entity_type = "user"
entity_name = "User:CN=pubsub/example-producer"
entity_type = "user"
config = {
# limit producing to 5 MB/s
"producer_byte_rate" = "5242880"
Expand Down Expand Up @@ -53,8 +53,8 @@ resource "kafka_acl" "example_consume_process_individually_group_access" {
}

resource "kafka_quota" "example_consume_process_individually_quota" {
entity_name = "User:CN=pubsub/example-consume-process-individually"
entity_type = "user"
entity_name = "User:CN=pubsub/example-consume-process-individually"
entity_type = "user"
config = {
# limit consuming to 5 MB/s
"consumer_byte_rate" = "5242880"
Expand Down
Loading

0 comments on commit 6aedd9a

Please sign in to comment.