Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / visualise-network-traffic-main-vpc-02.yaml
Created March 27, 2024 12:39
contents of the main.tf file from the blog-visualise-network-traffic repository
# create the internet gateway so that we can connect to the internet
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main.id
tags = {
Name = "igw"
}
}
@nivleshc
nivleshc / visualise-network-traffic-main-vpc-01.yaml
Created March 27, 2024 12:35
main.tf file from the blog-visualise-network-trraffic repository
# create the private subnet
resource "aws_subnet" "private" {
vpc_id = aws_vpc.main.id
cidr_block = var.private_subnet["cidr_block"]
availability_zone = var.private_subnet["availability_zone"]
tags = var.private_subnet["tags"]
}
# create the public subnet. This is where the Grafana Server will be installed
# create the VPC
resource "aws_vpc" "main" {
cidr_block = var.vpc["cidr_block"]
instance_tenancy = var.vpc["instance_tenancy"]
tags = var.vpc["tags"]
}
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-06.tf
Created July 24, 2023 11:08
This gist contains the sixth part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
output "grafana_service_ingress_http_hostname" {
description = "Grafana service ingress hostname"
value = kubernetes_ingress_v1.grafana.status[0].load_balancer[0].ingress[0].hostname
depends_on = [
kubernetes_ingress_v1.grafana
]
}
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-05.tf
Created July 24, 2023 11:06
This gist contains the fifth part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
resource "aws_ssm_parameter" "grafana_admin_username" {
name = local.grafana.admin_credentials.username_ssm_parameter_path
type = "SecureString"
value = data.kubernetes_secret_v1.grafana_admin_credentials.binary_data.admin-user
depends_on = [
data.kubernetes_secret_v1.grafana_admin_credentials
]
}
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-04.tf
Created July 24, 2023 11:03
This gist contains the fourth part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
data "kubernetes_secret_v1" "grafana_admin_credentials" {
metadata {
name = local.grafana.name
namespace = kubernetes_namespace.grafana.id
}
binary_data = {
"admin-password" = ""
"admin-user" = ""
"ldap-toml" = ""
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-03.tf
Created July 24, 2023 11:00
This gist contains the third part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
resource "kubernetes_ingress_v1" "grafana" {
metadata {
name = local.grafana.name
namespace = kubernetes_namespace.grafana.id
annotations = {
"alb.ingress.kubernetes.io/scheme" = local.grafana.ingress.annotations.scheme
"alb.ingress.kubernetes.io/target-type" = local.grafana.ingress.annotations.target_type
}
labels = {
"app.kubernetes.io/name" = local.grafana.name
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-values-grafana.tftpl
Created July 24, 2023 10:28
This gist contains values that are used when provisioning Grafana using a Helm chart. The contents have been extracted from the file called grafana.tftpl which is located inside the values subfolder, which is part of the blog-tf-pipeline-eks-cluster repository.
service:
enabled: true
type: NodePort
port: ${service_port}
targetPort: 3000
annotations: {}
labels: {}
portName: service
appProtocol: ""
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-02.tf
Created July 24, 2023 10:22
This gist contains the second part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
resource "helm_release" "grafana" {
name = local.grafana.name
repository = local.grafana.helm.repository
chart = local.grafana.helm.chart.name
version = local.grafana.helm.chart.version
namespace = kubernetes_namespace.grafana.id
values = [
templatefile(local.grafana.helm.values_filename, { service_port = local.grafana.service_port, namespace = "${kubernetes_namespace.prometheus.id}", grafana_dashboards = fileset("${path.module}/grafana_dashboards/", "*.json"), module_path = "${path.module}" })
@nivleshc
nivleshc / blog-tf-pipeline-eks-cluster-monitoring-grafana-01.tf
Created July 24, 2023 10:19
This gist contains the first part of the file grafana.tf which is contained in the blog-tf-pipeline-eks-cluster repository.
resource "kubernetes_namespace" "grafana" {
metadata {
name = local.grafana.namespace
}
depends_on = [
aws_eks_cluster.eks_cluster
]
}