Skip to content

Instantly share code, notes, and snippets.

View guivin's full-sized avatar

Guillaume Vincent guivin

View GitHub Profile
@guivin
guivin / .pre-commit-config.yaml
Created April 4, 2022 11:37
Terraform pre-commit configuration
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.62.3
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs
args:
- '--args=--lockfile=false'
- id: terraform_tflint
@guivin
guivin / .tflint.hcl
Created April 4, 2022 11:35
TFLint configuration example
config {
force = false
disabled_by_default = false
}
plugin "aws" {
enabled = true
version = "0.12.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
@guivin
guivin / main.tf
Created April 4, 2022 11:34
terraform_tflint_example
provider "aws" {
region = "missing"
}
resource "aws_instance" "foo" {
ami = "ami-0ff8a91507f77f867"
instance_type = "wrong" # invalid type!
}
@guivin
guivin / main.tf
Created April 4, 2022 09:50
terraform-typos
provider "aws" {
region = "us-east-1"
}
resource "aws_instanc" "foo" {
ami = "ami-0ff8a91507f77f867"
instance_type = "t2.small"
}
@guivin
guivin / grafana.tf
Created March 23, 2022 08:02
grafana.tf
resource "kubernetes_secret" "grafana" {
metadata {
name = "grafana"
namespace = var.namespace
}
data = {
admin-user = "admin"
admin-password = random_password.grafana.result
}
@guivin
guivin / prometheus.tf
Created March 23, 2022 08:00
prometheus.tf
resource "helm_release" "prometheus" {
chart = "prometheus"
name = "prometheus"
namespace = var.namespace
repository = "https://prometheus-community.github.io/helm-charts"
version = "15.5.3"
set {
name = "podSecurityPolicy.enabled"
value = true
@guivin
guivin / providers.tf
Created March 23, 2022 07:58
providers.tf
provider "helm" {
# Several Kubernetes authentication methods are possible: https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication
kubernetes {
config_path = pathexpand(var.kube_config)
}
}
provider "kubernetes" {
config_path = pathexpand(var.kube_config)
}
@guivin
guivin / namespace.tf
Created March 23, 2022 07:56
namespace.tf
# Creating namespace with the Kubernetes provider is better than auto-creation in the helm_release.
# You can reuse the namespace and customize it with quotas and labels.
resource "kubernetes_namespace" "monitoring" {
metadata {
name = var.namespace
}
}
@guivin
guivin / variables.tf
Created March 23, 2022 07:54
variables.tf
variable "kube_config" {
type = string
default = "~/.kube/config"
}
variable "namespace" {
type = string
default = "monitoring"
}
@guivin
guivin / namespace.tf
Created March 22, 2022 08:14
namespace.tf
resource "kubernetes_namespace" "this" {
metadata {
name = var.namespace
}
}