Streaming Progress With Pulumi Automation API

When using the pulumi automation API, you lose some of the niceties of the pulumi CLI, like having to set up command line args processing and the output is not as friendly or pretty as before. It also doesn’t stream the output – though this one is easier to fix.

This is lifted straight out of their golang example code, so if you’re working in another language – you should be able to find the relevant code in the same repo

	// wire up our update to stream progress to stdout
	stdoutStreamer := optup.ProgressStreams(os.Stdout)

	// run the update to deploy our fargate web service
	res, err := stack.Up(ctx, stdoutStreamer)
	if err != nil {
		fmt.Printf("Failed to update stack: %v\n\n", err)
	}

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.