> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pulumi Provider

> Manage Control Plane resources as infrastructure-as-code using the official Pulumi provider with JavaScript, Python, Go, or .NET.

The Control Plane Pulumi provider lets you manage Control Plane resources as code across JavaScript/TypeScript, Python, Go, and .NET (C#).

<Card title="Pulumi Registry" icon="arrow-up-right-from-square" href="https://www.pulumi.com/registry/packages/cpln">
  View the official Control Plane provider on the Pulumi Registry for full documentation, resources, and data sources.
</Card>

## Install Pulumi CLI

<Tabs>
  <Tab title="Windows">
    ```bash theme={null}
    choco install pulumi
    ```
  </Tab>

  <Tab title="macOS">
    ```bash theme={null}
    brew install pulumi
    ```
  </Tab>

  <Tab title="Linux">
    ```bash theme={null}
    curl -fsSL https://get.pulumi.com | sh
    ```
  </Tab>
</Tabs>

<Note>
  Need a different installer or hit an error? Check Pulumi’s download & install guide for platform-specific binaries, installer options, and troubleshooting tips: [Pulumi Download & Install](https://www.pulumi.com/docs/iac/download-install)
</Note>

## Login to Manage Pulumi State

By default, Pulumi stores state in the Pulumi Service. To authenticate:

```bash theme={null}
pulumi login
```

This opens a browser to sign in.

## Create a New Pulumi Project

<Steps>
  <Step title="Create Directory">
    Create an empty directory, e.g:

    ```bash theme={null}
    mkdir pulumi-cpln-infra && cd pulumi-cpln-infra
    ```
  </Step>

  <Step title="Initialize Project">
    Run the Pulumi project initializer:

    <Tabs>
      <Tab title="JavaScript">
        ```bash theme={null}
        pulumi new javascript
        ```
      </Tab>

      <Tab title="TypeScript">
        ```bash theme={null}
        pulumi new typescript
        ```
      </Tab>

      <Tab title="Python">
        ```bash theme={null}
        pulumi new python
        ```
      </Tab>

      <Tab title="Go">
        ```bash theme={null}
        pulumi new go
        ```
      </Tab>

      <Tab title=".NET (C#)">
        ```bash theme={null}
        pulumi new csharp
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Select Language">
    From the list of templates, choose your language (TypeScript, Python, Go, .NET (C#)).
  </Step>

  <Step title="Project Name">
    Enter a project name (e.g. `pulumi-cpln-infra`).
  </Step>

  <Step title="Stack Name">
    Accept or change the default stack name (`dev`).
  </Step>
</Steps>

The initializer will scaffold a basic project for your chosen language; you’ll add the Control Plane provider next.

## Install the Control Plane Provider

<Tabs>
  <Tab title="JavaScript/TypeScript">
    ```bash theme={null}
    # npm
    npm install @pulumiverse/cpln

    # yarn
    yarn add @pulumiverse/cpln

    # pnpm
    pnpm add @pulumiverse/cpln
    ```
  </Tab>

  <Tab title="Python">
    ```bash theme={null}
    pip install pulumiverse-cpln
    ```
  </Tab>

  <Tab title="Go">
    ```bash theme={null}
    go get github.com/pulumiverse/pulumi-cpln/sdk/go/cpln
    ```
  </Tab>

  <Tab title=".NET (C#)">
    ```bash theme={null}
    dotnet add package Pulumiverse.cpln
    ```
  </Tab>
</Tabs>

## Upgrading the Provider

Keep your Pulumi Control Plane provider up to date by upgrading the package in your project:

<Tabs>
  <Tab title="JavaScript/TypeScript">
    ```bash theme={null}
    # npm
    npm install @pulumiverse/cpln@latest

    # yarn
    yarn upgrade @pulumiverse/cpln@latest

    # pnpm
    pnpm add @pulumiverse/cpln@latest
    ```
  </Tab>

  <Tab title="Python">
    ```bash theme={null}
    pip install --upgrade pulumiverse-cpln
    ```
  </Tab>

  <Tab title="Go">
    ```bash theme={null}
    go get -u github.com/pulumiverse/pulumi-cpln/sdk/go/cpln
    ```
  </Tab>

  <Tab title=".NET (C#)">
    ```bash theme={null}
    dotnet add package Pulumiverse.Cpln
    ```
  </Tab>
</Tabs>

<Tip>🔄 After upgrading, run pulumi up to apply any necessary changes.</Tip>

## Configure the Provider

For more configuration information refer to the [Control Plane Installation & Configuration](https://www.pulumi.com/registry/packages/cpln/installation-configuration) page.

Set your Control Plane provider configuration:

```bash theme={null}
# Required
pulumi config set cpln:org                   <your-org>

# Optional
pulumi config set cpln:endpoint              <api-endpoint-url>
pulumi config set cpln:profile               <profile-name>
pulumi config set --secret cpln:token        <your-token>
pulumi config set --secret cpln:refreshToken <your-refresh-token>
```

### Using Environment Variables

You can also supply your Control Plane credentials via environment variables.

| Option         | Env Var              | Default                            |
| -------------- | -------------------- | ---------------------------------- |
| `org`          | `CPLN_ORG`           | None (Required)                    |
| `endpoint`     | `CPLN_ENDPOINT`      | `https://api.cpln.io` (Optional)   |
| `profile`      | `CPLN_PROFILE`       | The default CLI profile (Optional) |
| `token`        | `CPLN_TOKEN`         | None (Optional)                    |
| `refreshToken` | `CPLN_REFRESH_TOKEN` | None (Optional)                    |

## Create & Deploy a Resource

### Defining Resource

Edit the generated code (e.g. `index.ts`, `__main__.py`, `main.go`, `Program.cs`) to define a resource.

<Tabs>
  <Tab title="JavaScript/TypeScript">
    ```javascript theme={null}
    import * as pulumi from '@pulumi/pulumi';
    import * as cpln from '@pulumiverse/cpln';

    const gvc = new cpln.Gvc('example', {
      name: 'example',
      // …other args
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import pulumi
    import pulumiverse_cpln as cpln

    gvc = cpln.Gvc("example",
        name="example",
        # …other args
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    package main

    import (
      "github.com/pulumiverse/pulumi-cpln/sdk/go/cpln"
      "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )

    func main() {
      pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := cpln.NewGvc(ctx, "example", &cpln.GvcArgs{
          Name: pulumi.String("example"),
          // …other args
        })
        return err
      })
    }
    ```
  </Tab>

  <Tab title=".NET (C#)">
    ```csharp theme={null}
    using System.Collections.Generic;
    using Pulumi;
    using Pulumiverse.Cpln;

    return await Deployment.RunAsync(() =>
    {
        // Add your resources here
        var gvc = new Gvc("example", new GvcArgs {
          Name = "example",
          // …other args
        });

        // Export outputs here
        return new Dictionary<string, object?> { };
    });
    ```
  </Tab>
</Tabs>

<Tip>
  Refer to the [Pulumi GVC resource documentation](https://www.pulumi.com/registry/packages/cpln/api-docs/gvc) page for the full list of args.
</Tip>

### Deploying Resource

Run the following command to deploy your resources to the Control Plane platform:

```bash theme={null}
pulumi up
```

### Destroying Resource

When you need to tear down your Control Plane infrastructure, run the following command:

```bash theme={null}
pulumi destroy
```

### Removing the Stack

After destroying resources, you can delete the stack itself:

```bash theme={null}
pulumi stack rm
```

## Migrating from Terraform

If you’re moving existing Terraform projects to Pulumi, you can:

<Steps>
  <Step title="Convert HCL to Pulumi Code">
    Ensure your Terraform configuration files are in the current working directory, then run the converter:

    <Tabs>
      <Tab title="JavaScript">
        ```bash theme={null}
        pulumi convert --from terraform --language javascript --out pulumi-cpln-infra-javascript
        ```
      </Tab>

      <Tab title="TypeScript">
        ```bash theme={null}
        pulumi convert --from terraform --language typescript --out pulumi-cpln-infra-typescript
        ```
      </Tab>

      <Tab title="Python">
        ```bash theme={null}
        pulumi convert --from terraform --language python --out pulumi-cpln-infra-python
        ```
      </Tab>

      <Tab title="Go">
        ```bash theme={null}
        pulumi convert --from terraform --language go --out pulumi-cpln-infra-go
        ```
      </Tab>

      <Tab title=".NET (C#)">
        ```bash theme={null}
        pulumi convert --from terraform --language csharp --out pulumi-cpln-infra-csharp
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Create a New Pulumi Stack">
    Before importing your Terraform state, initialize (or select) a Pulumi stack to hold it. Replace `<stackName>` with your desired name (e.g. `migrate`):

    ```bash theme={null}
    pulumi stack init migrate
    ```
  </Step>

  <Step title="Import Terraform State">
    Specify the correct path to your Terraform state file, then run the import command:

    ```bash theme={null}
    pulumi import --from terraform /path/to/terraform.tfstate
    ```

    Replace `/path/to/terraform.tfstate` with the location of your state file. This reads the specified state and merges its resources into your Pulumi stack’s state.
  </Step>

  <Step title="Review Code">Review and refine the generated Pulumi code.</Step>
</Steps>

For full details, examples, and advanced workflows, see the Pulumi guide on [Migrating from Terraform to Pulumi](https://www.pulumi.com/docs/iac/adopting-pulumi/migrating-to-pulumi/from-terraform).

## Next Steps

Dive into all Control Plane resources & data sources at the [Control Plane Pulumi Registry](https://www.pulumi.com/registry/packages/cpln). Check the registry docs regularly for new releases, resources, and data sources.
