feat: add pre-commit check in ci
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful
- add a ci workflow to verify pre-commit passes - fix pre-commit errors/warnings: - missing required_version - missing required_providers - fixed terraform_deprecated_interpolation - removed terraform_unused_declarations
This commit is contained in:
parent
9e6de4dc32
commit
66119e5207
9
.woodpecker/pre-commit.yaml
Normal file
9
.woodpecker/pre-commit.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
when:
|
||||||
|
- event: pull_request
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: pre-commit
|
||||||
|
image: git.unkin.net/unkin/almalinux9-base:latest
|
||||||
|
commands:
|
||||||
|
- dnf install uv opentofu terragrunt tflint -y
|
||||||
|
- uvx pre-commit run --all-files
|
||||||
11
modules/vault_cluster/.tflint.hcl
Normal file
11
modules/vault_cluster/.tflint.hcl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
rule "terraform_required_providers" {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
rule "terraform_required_version" {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
rule "terraform_unused_declarations" {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
@ -3,8 +3,6 @@ module "auth_approle_backend" {
|
|||||||
|
|
||||||
for_each = var.auth_approle_backend
|
for_each = var.auth_approle_backend
|
||||||
|
|
||||||
country = var.country
|
|
||||||
region = var.region
|
|
||||||
path = each.key
|
path = each.key
|
||||||
listing_visibility = each.value.listing_visibility
|
listing_visibility = each.value.listing_visibility
|
||||||
default_lease_ttl = each.value.default_lease_ttl
|
default_lease_ttl = each.value.default_lease_ttl
|
||||||
@ -186,7 +184,6 @@ module "pki_secret_backend" {
|
|||||||
crl_distribution_points = each.value.crl_distribution_points
|
crl_distribution_points = each.value.crl_distribution_points
|
||||||
ocsp_servers = each.value.ocsp_servers
|
ocsp_servers = each.value.ocsp_servers
|
||||||
enable_templating = each.value.enable_templating
|
enable_templating = each.value.enable_templating
|
||||||
default_issuer_ref = each.value.default_issuer_ref
|
|
||||||
default_follows_latest_issuer = each.value.default_follows_latest_issuer
|
default_follows_latest_issuer = each.value.default_follows_latest_issuer
|
||||||
crl_expiry = each.value.crl_expiry
|
crl_expiry = each.value.crl_expiry
|
||||||
crl_disable = each.value.crl_disable
|
crl_disable = each.value.crl_disable
|
||||||
@ -266,12 +263,11 @@ module "consul_secret_backend_role" {
|
|||||||
|
|
||||||
for_each = var.consul_secret_backend_role
|
for_each = var.consul_secret_backend_role
|
||||||
|
|
||||||
name = each.value.name
|
name = each.value.name
|
||||||
backend = each.value.backend
|
backend = each.value.backend
|
||||||
consul_roles = each.value.consul_roles
|
ttl = each.value.ttl
|
||||||
ttl = each.value.ttl
|
max_ttl = each.value.max_ttl
|
||||||
max_ttl = each.value.max_ttl
|
local = each.value.local
|
||||||
local = each.value.local
|
|
||||||
|
|
||||||
depends_on = [module.consul_secret_backend, module.consul_acl_management]
|
depends_on = [module.consul_secret_backend, module.consul_acl_management]
|
||||||
}
|
}
|
||||||
@ -324,7 +320,6 @@ module "pki_mount_only" {
|
|||||||
path = each.key
|
path = each.key
|
||||||
description = each.value.description
|
description = each.value.description
|
||||||
max_lease_ttl_seconds = each.value.max_lease_ttl_seconds
|
max_lease_ttl_seconds = each.value.max_lease_ttl_seconds
|
||||||
issuer_ref = each.value.issuer_ref
|
|
||||||
issuing_certificates = each.value.issuing_certificates
|
issuing_certificates = each.value.issuing_certificates
|
||||||
crl_distribution_points = each.value.crl_distribution_points
|
crl_distribution_points = each.value.crl_distribution_points
|
||||||
ocsp_servers = each.value.ocsp_servers
|
ocsp_servers = each.value.ocsp_servers
|
||||||
|
|||||||
@ -8,4 +8,4 @@ resource "vault_auth_backend" "approle" {
|
|||||||
max_lease_ttl = var.max_lease_ttl
|
max_lease_ttl = var.max_lease_ttl
|
||||||
listing_visibility = var.listing_visibility
|
listing_visibility = var.listing_visibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,3 @@
|
|||||||
variable "country" {
|
|
||||||
description = "Country identifier"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "Region identifier"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "path" {
|
variable "path" {
|
||||||
description = "Mount path of the AppRole auth backend"
|
description = "Mount path of the AppRole auth backend"
|
||||||
type = string
|
type = string
|
||||||
@ -34,4 +24,4 @@ variable "max_lease_ttl" {
|
|||||||
description = "Specifies the maximum time-to-live. If set, this overrides the global default. Must be a valid duration string"
|
description = "Specifies the maximum time-to-live. If set, this overrides the global default. Must be a valid duration string"
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ data "vault_kv_secret_v2" "role_config" {
|
|||||||
locals {
|
locals {
|
||||||
salt = data.vault_kv_secret_v2.salt_config.data["salt"]
|
salt = data.vault_kv_secret_v2.salt_config.data["salt"]
|
||||||
role_id_input = "${local.salt}-${var.approle_name}-${var.mount_path}"
|
role_id_input = "${local.salt}-${var.approle_name}-${var.mount_path}"
|
||||||
deterministic_role_id = uuidv5("dns", "${local.role_id_input}")
|
deterministic_role_id = uuidv5("dns", local.role_id_input)
|
||||||
|
|
||||||
# Use deterministic role-id by default, or read from KV if specified
|
# Use deterministic role-id by default, or read from KV if specified
|
||||||
role_id = var.use_deterministic_role_id ? local.deterministic_role_id : data.vault_kv_secret_v2.role_config[0].data["role_id"]
|
role_id = var.use_deterministic_role_id ? local.deterministic_role_id : data.vault_kv_secret_v2.role_config[0].data["role_id"]
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,4 +4,4 @@ rule "terraform_required_providers" {
|
|||||||
|
|
||||||
rule "terraform_required_version" {
|
rule "terraform_required_version" {
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
consul = {
|
||||||
|
source = "hashicorp/consul"
|
||||||
|
version = "2.23.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,12 +9,6 @@ variable "name" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
variable "consul_roles" {
|
|
||||||
description = "List of Consul roles to attach to tokens"
|
|
||||||
type = list(string)
|
|
||||||
default = []
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
variable "ttl" {
|
variable "ttl" {
|
||||||
description = "TTL for generated tokens"
|
description = "TTL for generated tokens"
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,11 +5,6 @@ resource "vault_mount" "pki" {
|
|||||||
max_lease_ttl_seconds = var.max_lease_ttl_seconds
|
max_lease_ttl_seconds = var.max_lease_ttl_seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
data "vault_pki_secret_backend_issuer" "issuer" {
|
|
||||||
backend = vault_mount.pki.path
|
|
||||||
issuer_ref = var.issuer_ref
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "vault_pki_secret_backend_config_urls" "config_urls" {
|
resource "vault_pki_secret_backend_config_urls" "config_urls" {
|
||||||
backend = vault_mount.pki.path
|
backend = vault_mount.pki.path
|
||||||
|
|
||||||
@ -35,4 +30,4 @@ resource "vault_pki_secret_backend_crl_config" "crl" {
|
|||||||
auto_rebuild = var.auto_rebuild
|
auto_rebuild = var.auto_rebuild
|
||||||
enable_delta = var.enable_delta
|
enable_delta = var.enable_delta
|
||||||
delta_rebuild_interval = var.delta_rebuild_interval
|
delta_rebuild_interval = var.delta_rebuild_interval
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,11 +13,6 @@ variable "max_lease_ttl_seconds" {
|
|||||||
type = number
|
type = number
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "issuer_ref" {
|
|
||||||
description = "Reference to the PKI issuer (default, or issuer ID/name)"
|
|
||||||
type = string
|
|
||||||
default = "default"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "issuing_certificates" {
|
variable "issuing_certificates" {
|
||||||
description = "List of URLs for issuing certificates"
|
description = "List of URLs for issuing certificates"
|
||||||
@ -89,4 +84,4 @@ variable "delta_rebuild_interval" {
|
|||||||
description = "Delta CRL rebuild interval"
|
description = "Delta CRL rebuild interval"
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -61,12 +61,6 @@ variable "enable_templating" {
|
|||||||
default = false
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "default_issuer_ref" {
|
|
||||||
description = "Reference to the default issuer"
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "default_follows_latest_issuer" {
|
variable "default_follows_latest_issuer" {
|
||||||
description = "Whether the default issuer should follow the latest issuer"
|
description = "Whether the default issuer should follow the latest issuer"
|
||||||
type = bool
|
type = bool
|
||||||
@ -107,4 +101,4 @@ variable "delta_rebuild_interval" {
|
|||||||
description = "Delta CRL rebuild interval"
|
description = "Delta CRL rebuild interval"
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
modules/vault_cluster/modules/vault_policy/terraform.tf
Normal file
9
modules/vault_cluster/modules/vault_policy/terraform.tf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.10"
|
||||||
|
required_providers {
|
||||||
|
vault = {
|
||||||
|
source = "hashicorp/vault"
|
||||||
|
version = "5.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -166,7 +166,6 @@ variable "pki_secret_backend" {
|
|||||||
crl_distribution_points = optional(list(string), [])
|
crl_distribution_points = optional(list(string), [])
|
||||||
ocsp_servers = optional(list(string), [])
|
ocsp_servers = optional(list(string), [])
|
||||||
enable_templating = optional(bool, false)
|
enable_templating = optional(bool, false)
|
||||||
default_issuer_ref = optional(string)
|
|
||||||
default_follows_latest_issuer = optional(bool, false)
|
default_follows_latest_issuer = optional(bool, false)
|
||||||
crl_expiry = optional(string, "72h")
|
crl_expiry = optional(string, "72h")
|
||||||
crl_disable = optional(bool, false)
|
crl_disable = optional(bool, false)
|
||||||
@ -204,7 +203,6 @@ variable "pki_mount_only" {
|
|||||||
type = map(object({
|
type = map(object({
|
||||||
description = optional(string)
|
description = optional(string)
|
||||||
max_lease_ttl_seconds = optional(number, 315360000)
|
max_lease_ttl_seconds = optional(number, 315360000)
|
||||||
issuer_ref = optional(string, "default")
|
|
||||||
issuing_certificates = optional(list(string), [])
|
issuing_certificates = optional(list(string), [])
|
||||||
crl_distribution_points = optional(list(string), [])
|
crl_distribution_points = optional(list(string), [])
|
||||||
ocsp_servers = optional(list(string), [])
|
ocsp_servers = optional(list(string), [])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user