How to get current Function URL (aws-lambda + golang)

When deploying a function lambda that needs details of its own function URL. It’s an OAuth Callback, and needs to calculate the redirect. There are possible security issues doing it this way, so will switch to http gateway on launch. In the meantime, though, I ran into a bit of a chicken and egg problem.

In Pulumi, the function URL is created after the function (and even otherwise), I can’t pass the output of the lambda (or lambdaFunctionUrl) back in as an environment variable. Fortunately, there is an easy way to pick up the Function URL (or the function name for that matter) – if you know how 😉

	domainName := request.RequestContext.DomainName
	funcName := os.Getenv("AWS_LAMBDA_FUNCTION_NAME")
	return fmt.Sprintf("Domain: %s, funcName: %s", domainName, funcName), nil

There are other defined lambda function environment variables as well that you can use.