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

Fix weird Terraform bugs with Dapr config files #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
83 changes: 33 additions & 50 deletions dapr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,44 @@ resource "helm_release" "redis" {
}
}

# -- comment out the two resources below when initially creating the cluster, somehow this fails to plan on the first run

resource "kubernetes_manifest" "dapr_state_config" {
resource "kubectl_manifest" "dapr_state_config" {
depends_on = [kubernetes_namespace.gits]
manifest = {
"apiVersion" = "dapr.io/v1alpha1"
"kind" = "Component"
"metadata" = {
"name" = "statestore"
namespace = kubernetes_namespace.gits.metadata[0].name
}
"spec" = {
"type" = "state.redis"
"version" = "v1"

"metadata" = [
{
"name" = "redisHost"
"value" = "redis-master:6379"
},
{
"name" = "redisPassword"
"value" = random_password.redis.result
}
]
}
}
}
yaml_body = <<-EOF
apiVersion: "dapr.io/v1alpha1"
kind: "Component"
metadata:
name: "statestore"
namespace: ${kubernetes_namespace.gits.metadata[0].name}

spec:
type: "state.redis"
version: "v1"

metadata:
- name: "redisHost"
value: "redis-master:6379"
- name: "redisPassword"
value: ${random_password.redis.result}
EOF
}

resource "kubernetes_manifest" "dapr_pubsub_config" {
resource "kubectl_manifest" "dapr_pubsub_config" {
depends_on = [kubernetes_namespace.gits]
manifest = {
"apiVersion" = "dapr.io/v1alpha1"
"kind" = "Component"
"metadata" = {
"name" = "gits"
namespace = kubernetes_namespace.gits.metadata[0].name
}
yaml_body = <<-EOF
apiVersion: "dapr.io/v1alpha1"
kind: "Component"
metadata:
name: "gits"
namespace: ${kubernetes_namespace.gits.metadata[0].name}

"spec" = {
"type" = "pubsub.redis"
"version" = "v1"
spec:
type: "pubsub.redis"
version: "v1"

"metadata" = [
{
"name" = "redisHost"
"value" = "redis-master:6379"
},
{
"name" = "redisPassword"
"value" = random_password.redis.result
}
]
}
}
metadata:
- name: "redisHost"
value: "redis-master:6379"
- name: "redisPassword"
value: ${random_password.redis.result}
EOF
}
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = "~> 1.14.0"
}
}
}

provider "kubernetes" {
config_path = "./kubeconfig.yaml"
}
Expand Down