RemoteBackend with Python

What is the correct way to define a RemoteBackend for cdk with Python? I tried the following based on the blog example, but it didn’t work.

from cdktf import App, TerraformStack, TerraformOutput, RemoteBackend
<snip>
stack = MyStack(app, "hello-terraform")
RemoteBackend(stack,
    hostname= "app.terraform.io",
    organization="test-cdk-org",
    workspaces= {"name": 'hello-terraform'}
)

Thanks for raising this question. workspaces expects an object of a class which implements the IRemoteWorkspace interface. That would be either the class NamedRemoteWorkspace or PrefixedRemoteWorkspaces from the cdktf package.

A working RemoteBackend would look like this:

RemoteBackend(stack,
    hostname= "app.terraform.io",
    organization="pphan-servicenow",
    workspaces=NamedRemoteWorkspace(name='hello-terraform')
)

@jsteinich do you remember why the workspace values are wrapped in classes rather than an interface?

Thanks @skorfmann!

Your example above with the following line worked for me.
from cdktf import RemoteBackend, NamedRemoteWorkspace

Was missing NamedRemoteWorkspace earlier.

I believe that’s trying to indicate that name and prefix are conflicting options.
Even if it were an interface, workspaces= {"name": 'hello-terraform'} might not work due to some limitations in jsii