Control Plane Provider
Installation
The Control Plane provider is available as a package in all Pulumi languages:
- JavaScript/TypeScript:
@pulumi/cpln
- Python:
pulumi-cpln
- Go:
github.com/pulumiverse/pulumi-cpln/sdk/go/cpln
- .NET:
Pulumi.Cpln
- Java:
com.pulumi/cpln
Overview
The Control Plane Pulumi Provider Plugin enables the scaffolding of any Control Plane object as code using HCL. It enables infrastructure as code with all the added benefit of the global virtual cloud (GVC). You can build your VPCs, subnets, databases, queues, caches, etc. and overlay them with a multi-cloud/multi-region universal compute workloads that span regions and clouds. Nearly everything you can do using the Control Plane CLI, UI or API is available using Pulumi.
Each header below (i.e., cpln.Agent
) corresponds to a resource within the Control Plane Pulumi provider.
Authentication
Authenticate using one of the following methods:
1. CLI
- Install the CLI and execute the command
cpln login
. After a successful login, the Pulumi provider will use thedefault
profile to authenticate. To use a different profile, set theprofile
variable when initializing the provider or set theCPLN_PROFILE
environment variable.
2. Token
- The
token
variable can be set when initializing the provider or by setting theCPLN_TOKEN
environment variable. - The value of
token
can be either:- The output of running the command
cpln profile token PROFILE_NAME
, or - In the case of a Service Account, the value of one of it’s keys
- The output of running the command
3. Refresh Token
- The
refreshToken
variable is used when the provider is required to create an org or update theauthConfig
property using thecpln.Org
resource. TherefreshToken
variable can be set when initializing the provider or by setting theCPLN_REFRESH_TOKEN
environment variable. - When creating an org, the
refreshToken
must belong to a user that has theorgCreator
role for the associated account. - When updating the org
authConfig
property, therefreshToken
must belong to a user that was authenticated using SAML. - The
refreshToken
can be obtained by following these steps:- Using the CLI, authenticate with a user account by executing
cpln login
. - Browser to the path
~/.config/cpln/profiles
. This path will contain JSON files corresponding to the name of the profile (i.e.,default.json
). - The contents of the JSON file will contain a key named
refreshToken
. Use the value of this key for therefreshToken
variable.
- Using the CLI, authenticate with a user account by executing
Note To perform automated tasks using Pulumi, the preferred method is to use a
Service Account
and one of it’skeys
as thetoken
value.
Provider Declaration
Required
org (String) The Control Plane org that this provider will perform actions against. Can be specified with the
CPLN_ORG
environment variable.endpoint (String) The Control Plane Data Service API endpoint. Default is:
https://api.cpln.io
. Can be specified with theCPLN_ENDPOINT
environment variable.profile (String) The user/service account profile that this provider will use to authenticate to the data service. Can be specified with the
CPLN_PROFILE
environment variable.token (String) A generated token that can be used to authenticate to the data service API. Can be specified with the
CPLN_TOKEN
environment variable.refresh_token (String) A generated token that can be used to authenticate to the data service API. Can be specified with the
CPLN_REFRESH_TOKEN
environment variable. Used when the provider is required to create an org or update theauthConfig
property. Refer to the section above on how to obtain the refresh token.
Note If the
token
orrefreshToken
value is empty, the Control Plane CLI (cpln) must be installed and thecpln login
command must be used to authenticate.
Example Usage
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
import * as cpln from "@pulumiverse/cpln";
const group = new cpln.Group("example", {
description: "example",
});
export const groupId = group.id;
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
import pulumi
import pulumiverse_cpln as cpln
group = cpln.Group("example",
description="example"
)
pulumi.export("group.id", group.id)
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
using System.Collections.Generic;
using Pulumi;
using Pulumiverse.Cpln;
return await Deployment.RunAsync(() =>
{
var group = new Group("example", new GroupArgs{
Description = "example"
});
return new Dictionary<string, object?>
{
["group.id"] = group.Id
};
});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
package main
import (
"fmt"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
cpln "github.com/pulumiverse/pulumi-cpln/sdk/go/cpln"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
group, err := cpln.NewGroup(ctx, "example", &cpln.GroupArgs{
Description: pulumi.String("example"),
})
if err != nil {
return fmt.Errorf("error creating a group: %v", err)
}
ctx.Export("group.id", group.ID())
return nil
})
}
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
{}
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
cpln:endpoint:
value: "TODO: var.endpoint"
cpln:org:
value: "TODO: var.org"
cpln:profile:
value: "TODO: var.profile"
cpln:refreshToken:
value: "TODO: var.refresh_token"
cpln:token:
value: "TODO: var.token"
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
}
}