This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create the VPC | |
resource "aws_vpc" "main" { | |
cidr_block = var.vpc["cidr_block"] | |
instance_tenancy = var.vpc["instance_tenancy"] | |
tags = var.vpc["tags"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: | |
enabled: true | |
type: NodePort | |
port: ${service_port} | |
targetPort: 3000 | |
annotations: {} | |
labels: {} | |
portName: service | |
appProtocol: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "kubernetes_namespace" "grafana" { | |
metadata { | |
name = local.grafana.namespace | |
} | |
depends_on = [ | |
aws_eks_cluster.eks_cluster | |
] | |
} |