Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit config to run terraform fmt #137

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Checks
on:
push:
branches:
- main
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/[email protected]
- uses: actions/[email protected]
- uses: pre-commit/[email protected]
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
6 changes: 3 additions & 3 deletions dev-aws/kafka-shared/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ resource "kafka_topic" "iam_revoked_v1" {
name = "auth.iam-revoked-v1"
replication_factor = 3
partitions = 1
config = {
config = {
# retain 100MB on each partition
"retention.bytes" = "104857600"
"retention.bytes" = "104857600"
# 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 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 @@ -19,13 +19,13 @@ resource "kafka_topic" "otlp_spans" {
}

module "otel_collector" {
source = "../../modules/tls-app"
produce_topics = [kafka_topic.otlp_spans.name]
source = "../../modules/tls-app"
produce_topics = [kafka_topic.otlp_spans.name]
cert_common_name = "otel/collector"
}

module "tempo_distributor" {
source = "../../modules/tls-app"
consume_topics = {(kafka_topic.otlp_spans.name): "processor-tempo"}
source = "../../modules/tls-app"
consume_topics = { (kafka_topic.otlp_spans.name) : "processor-tempo" }
cert_common_name = "otel/tempo-distributor"
}
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
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"
}
4 changes: 2 additions & 2 deletions exp-1-merit/kafka-shared/pdp-audit.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ resource "kafka_topic" "iam_cerbos_audit_v1" {

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
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
12 changes: 6 additions & 6 deletions exp-1-merit/pubsub-msk/kafka-ui.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ 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"

depends_on = [kafka_acl.tf_applier_cluster]
Expand Down
12 changes: 6 additions & 6 deletions exp-1-merit/pubsub-msk/pubsub-examples.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ resource "kafka_topic" "pubsub_examples" {
"local.retention.ms" = "3600000"
# 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 @@ -27,8 +27,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 @@ -56,8 +56,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
12 changes: 6 additions & 6 deletions exp-1-merit/pubsub-msk/tf-applier.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ resource "kafka_acl" "tf_applier_group" {
}

resource "kafka_acl" "tf_applier_cluster" {
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/tf-applier"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_name = "kafka-cluster"
resource_type = "Cluster"
acl_principal = "User:CN=pubsub/tf-applier"
acl_host = "*"
acl_operation = "All"
acl_permission_type = "Allow"
resource_pattern_type_filter = "Literal"
}
2 changes: 1 addition & 1 deletion modules/tls-app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource "kafka_acl" "producer_acl" {
resource "kafka_quota" "quota" {
entity_name = "User:CN=${var.cert_common_name}"
entity_type = "user"
config = {
config = {
"consumer_byte_rate" = tostring(var.consumer_byte_rate)
"producer_byte_rate" = tostring(var.producer_byte_rate)
"request_percentage" = tostring(var.request_percentage)
Expand Down
2 changes: 1 addition & 1 deletion modules/tls-app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ variable "request_percentage" {
type = number
description = "The percentage of requests a specified entity is allowed to make."
# Allow 100% of CPU. More on this here: https://docs.confluent.io/kafka/design/quotas.html#request-rate-quotas
default = 100
default = 100

validation {
condition = var.request_percentage >= 0 && var.request_percentage <= 100
Expand Down
2 changes: 1 addition & 1 deletion prod-aws/finance/complaints-fabricator.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "kafka_topic" "complaints-eqdb-loader-events" {
partitions = 10
config = {
"retention.bytes" = "-1"
"retention.ms" = "-1"
"retention.ms" = "-1"
"cleanup.policy" = "delete"
}
}
2 changes: 1 addition & 1 deletion prod-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 = 10
config = {
Expand Down
2 changes: 1 addition & 1 deletion prod-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-v1-events" {
name = "disputes-diffs.v1-events"
name = "disputes-diffs.v1-events"
replication_factor = 3
partitions = 10
config = {
Expand Down
8 changes: 4 additions & 4 deletions prod-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 prod-aws/kafka-shared/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ resource "kafka_topic" "iam_revoked_v1" {
name = "auth.iam-revoked-v1"
replication_factor = 3
partitions = 1
config = {
config = {
# retain 100MB on each partition
"retention.bytes" = "104857600"
"retention.bytes" = "104857600"
# keep data for 60 days
"retention.ms" = "5184000000"
# allow max 1 MB for a message
Expand Down
Loading