# Lambda handler trigger temporal client and workflow creation

**URL:** https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302
**Category:** Community Support
**Tags:** go-sdk
**Created:** [March 29, 2022, 12:14am UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302 "2022-03-29T00:14:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sara](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sara](https://community.temporal.io/u/sara)
#### Post date: [March 29, 2022, 12:14am UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302/1 "2022-03-29T00:14:33Z")

</div>

I am trying to trigger a go function that will create a new client and execute temporal workflow by using lambda.Start(Handler) as the main point to trigger the whole workflow.

While I try to invoke the function the simple parameter passing works however creating a new client.NewClient(client.Options{}) did not work. It’s getting stuck with errors. Not sure what I am doing wring here.

```auto
func Handler(somedata workflow.Test) (string, error) {
	val, _ := json.MarshalIndent(somedata, "", " ")
	log.Printf(
		"\nvideopost: %s",
		string(val),
	)
	// Create the client object just once per process
	c, err := client.NewClient(client.Options{})
	if err != nil {
		log.Fatalln("unable to create Temporal client", err)
	}
	defer c.Close()
	return "test hurrah!", nil
}

func main() {
	lambda.Start(Handler)
}

```

any feedback/guidance is appreciated! Not sure if that’s related to any permission issues.

---

<div class="post-metadata">

### Author: ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)
#### Post date: [March 29, 2022, 1:22am UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302/2 "2022-03-29T01:22:32Z")

</div>

> It’s getting stuck with errors.

What errors are you getting? Are they Temporal or lambda specific?  
Also I’m not lambda expert so could be wrong, but looking at their [docs](https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html) I wonder if it would make sense to initialize Temporal client in the global `init` function rather than in the handler? Creating client is typically a heavy weight operation and could be created once in init and reused across multiple handler calls here.

---

<div class="post-metadata">

### Author: ![sara](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sara](https://community.temporal.io/u/sara)
#### Post date: [March 29, 2022, 1:42am UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302/3 "2022-03-29T01:42:46Z")

</div>

an error was just time out from serverless while initializing temporal client. I will give global init a shot probably that might resolve it.

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [March 29, 2022, 3:43am UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302/4 "2022-03-29T03:43:37Z")

</div>

Are you specifying the Temporal service endpoint in the client.Options?

---

<div class="post-metadata">

### Author: ![sara](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sara](https://community.temporal.io/u/sara)
#### Post date: [March 29, 2022, 9:51pm UTC](https://community.temporal.io/t/lambda-handler-trigger-temporal-client-and-workflow-creation/4302/5 "2022-03-29T21:51:38Z")

</div>

Nope, I was just testing things locally and kept everything simple. Similar to what’s out there in the tutorial . I was getting timeouts, It’s due to the permission issue. It took quite a long time to get back to the error. I am new to go and temporal, thanks @tihomir for the idea. However, in my case, there is going to be a single lambda handler. Lambda will get some event which in turn should initialize the temporal client and delegate that to EKS. Global init for initializing the temporal client wouldn’t make any difference since the memory is ephemeral.
