Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDU-3801: Update Money Transfer tutorial code to support Temporal Cloud #20

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomwheeler
Copy link

DO NOT MERGE.

I have created this draft PR to support review and sharing this code. However, I do not intend for this code to become part of the main branch, as it is my hope that what's on this branch will become obsolete when the SDKs support environment-based configuration.

What was changed

I added code to configure Temporal Client options based on the presence of environment variables. I also updated the Clients created by the Worker and Starter code to use it.

Why?

Currently, the clients used in this tutorial have no explicit configuration and rely solely on the default options. Imagine that someone new to Temporal application development signed up for Temporal Cloud on their own and now wants to run this intro-level money transfer tutorial. Getting it to work with Temporal Cloud requires making changes to the Client configuration, but this user won't know what to change. Note that this scenario I've described isn't limited to Temporal Cloud. Someone using a non-default Namespace name or a non-local Temporal Service would have the same problem.

Having the clients configure themselves based on the presence of environment variables eliminates the need to hardcode the frontend address, Namespace name, or authentication details. It helps the user understand that the application logic remains unchanged when migrating from the Temporal Service used for development on their laptop to a production Temporal Service (or vice versa). Finally, this makes it easier for users to run this example locally, on a remote self-hosted cluster, or on Temporal Cloud. Unfortunately, the SDKs do not support this yet (although it has been discussed), so this has to be done within the application itself in the interim.

NOTE: I have updated the code but not the prose in the tutorial, pending further discussion with the Education team. I plan to make similar changes to the other money-transfer repos, but if it turns out that is not viable, then I will probably need to fork these repos and tutorials to support the onboarding path for new cloud users.

Checklist

  1. Closes

This does not close an issue, but enables further progress of EDU-3801. That issue would be closed only after all similar tutorials have been updated.

  1. How was this tested:

I tested this in three scenarios:

Local Temporal Service (started via CLI) using the default namespace.

In this scenario, I set no environment variables. I ran the Worker and Starter code and the Workflow ran to completion.

Temporal Cloud, using mTLS

In this scenario, I set the four environment variables below (note that these values are similar to but not identical to the ones I actually set):

export TEMPORAL_ADDRESS='example.c9ef8.tmprl.cloud:7233'
export TEMPORAL_NAMESPACE='example.c9ef8'
export TEMPORAL_TLS_CERT='mycert.pem'
export TEMPORAL_TLS_KEY='mykey.key'

To verify that mTLS was used for authentication, I disabled API Keys for authentication on the Namespace in this scenario. I then ran the Worker and Starter code and the Workflow ran to completion.

Temporal Cloud, using API Keys

In this scenario, I set the three environment variables below (note that these values are similar to but not identical to the ones I actually set):

export TEMPORAL_ADDRESS='us-east-1.aws.api.temporal.io'
export TEMPORAL_NAMESPACE='example.c9ef8'
export TEMPORAL_API_KEY='abc123.actual.value.redacted.xyz789' 

To verify that the API keys were used for authentication, I disabled mTLS authentication on the Namespace in this scenario. I then ran the Worker and Starter code and the Workflow ran to completion.

  1. Any docs updates needed?

The tutorial prose will require a small update to describe the changes and explain which environment variables one must set for non-default scenarios.

@tomwheeler tomwheeler marked this pull request as draft February 10, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant