From 66404fde3a33bc157d4967c891ea861c115b56b5 Mon Sep 17 00:00:00 2001 From: Naeel Date: Wed, 15 Apr 2026 16:19:25 +0300 Subject: [PATCH] add: Go function example (tf-go-hello-fn) --- examples/go-hello/code/main.go | 11 ++++++++++ examples/go-hello/main.tf | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 examples/go-hello/code/main.go create mode 100644 examples/go-hello/main.tf diff --git a/examples/go-hello/code/main.go b/examples/go-hello/code/main.go new file mode 100644 index 0000000..1b6f3fa --- /dev/null +++ b/examples/go-hello/code/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + "net/http" +) + +func Handler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + fmt.Fprintf(w, "Hello from Go in Fission") +} diff --git a/examples/go-hello/main.tf b/examples/go-hello/main.tf new file mode 100644 index 0000000..ca9faeb --- /dev/null +++ b/examples/go-hello/main.tf @@ -0,0 +1,39 @@ +terraform { + required_providers { + fission = { + source = "nail/fission" + version = "~> 0.1.0" + } + } +} + +provider "fission" { + kubeconfig_path = "/home/naeel/.kube/config" + namespace = "default" +} + +resource "fission_environment" "go" { + name = "tf-go-hello-env" + image = "ghcr.io/fission/go-env" + version = 3 +} + +resource "fission_package" "pkg" { + name = "tf-go-hello-pkg" + environment = fission_environment.go.name + source_dir = "${path.module}/code" +} + +resource "fission_function" "fn" { + name = "tf-go-hello-fn" + environment = fission_environment.go.name + package_name = fission_package.pkg.name + entrypoint = "main.Handler" +} + +resource "fission_http_trigger" "route" { + name = "tf-go-hello-route" + function = fission_function.fn.name + url = "/go-hello" + methods = ["GET"] +}