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"] +}