#!/usr/bin/env python from constructs import Construct from cdktf import App, TerraformStack, CloudBackend, NamedCloudWorkspace from cdktf_cdktf_provider_tfe.workspace import Workspace from cdktf_cdktf_provider_tfe.project import Project from cdktf_cdktf_provider_tfe.provider import TfeProvider from util import read_input class MyStack(TerraformStack): def __init__(self, scope: Construct, id: str): super().__init__(scope, id) TfeProvider(self, "tfe", organization="'sample-org") result = Workspace(self, id_="ws_test_1", name="test_ws_1", organization="'sample-org") app = App() stack = MyStack(app, "workspace_configuration") CloudBackend(stack, hostname='app.terraform.io', organization='sample-org', workspaces=NamedCloudWorkspace('test_by_nitesh_ws') ) app.synth()
The error I am getting ,
│ Error: Error creating workspace test_ws_1 for organization sample-org: resource not found
│ with tfe_workspace.ws_test_1,
│ on cdk.tf.json line 30, in resource.tfe_workspace.ws_test_1:
│ 30: }
Operation failed: failed running terraform apply (exit 1)
I have ensured that I terraform login already setup up, I have TFE_TOKEN set as env. It fails at “apply” but shows “plan” as expected.
It is weird error !! I have corresponding terraform HCL based code which works fine. Please tell me if there is a bug with TFE provider in CDK.