1. Packages
  2. Civo Provider
civo 1.1.5 published on Thursday, Feb 6, 2025 by civo

Civo Provider

Generate Provider

The Civo provider must be installed as a Local Package by following the instructions for Any Terraform Provider:

pulumi package add terraform-provider civo/civo
Copy

Overview

The Civo provider is used to interact with the resources supported by Civo.

Use the navigation to the left to read about the available resources.

Configuration

The provider will use the credentials of the Civo CLI (stored in ~/.civo.json) if no other credentials have been set up. The provider will use credentials in the following order:

  1. Environment variable (CIVO_TOKEN).
  2. Token provided via a credentials file (See credentialsFile input below)
  3. CLI configuration (~/.civo.json)

That means that if the CIVO_TOKEN variable is set, all other credentials will be ignored, and if the credentialsFile is set, that will be used over the CLI credentials.

Obtaining a token

First you will need to create a Civo Account and then you can do the following:

  • If you can want to configure your credentials with the CLI, instructions are here
  • To fetch an API key go to the security section on the dashboard

Using the CIVO_TOKEN variable

To use the Civo token, export the variable containing your token:

export CIVO_TOKEN=<your token>
Copy

Using a credentials file

The format of the credentials file is as follows:

{
	"apikeys": {
		"tf_key": "write-your-token-here"
	},
	"meta": {
		"current_apikey": "tf_key"
	}
}
Copy

you will then need to configure the credentialsFile input to the correct location, for example:

credentialsFile = "/secure/path/civo.json"

Using the CLI

If you install the CLI and configure a token, there is nothing else you need to do if those are the credentials you wish to use, ideal for local usage.

Example Usage

Simplest usage

In this example the provider will look for credentials set by the CLI and use LON1 region as default, or use the environment variable CIVO_TOKEN if set.

# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
    civo:region:
        value: LON1
Copy
import * as pulumi from "@pulumi/pulumi";
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
    civo:region:
        value: LON1
Copy
import pulumi
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
    civo:region:
        value: LON1
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;

return await Deployment.RunAsync(() =>
{
});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
    civo:region:
        value: LON1
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		return nil
	})
}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
    civo:region:
        value: LON1
Copy
{}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
    civo:region:
        value: LON1
Copy
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) {
    }
}
Copy

Example with credentials file

In this example we are providing a specific version of the pulumi provider and setting a credentials file to use. The credentials file will be used if the environment variable CIVO_TOKEN is not set.

# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
import * as pulumi from "@pulumi/pulumi";
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
import pulumi
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;

return await Deployment.RunAsync(() =>
{
});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		return nil
	})
}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
{}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
    civo:credentialsFile:
        value: /secure/path/civo.json
    civo:region:
        value: LON1
Copy
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) {
    }
}
Copy

Configuration Reference

  • apiEndpoint (String) The Base URL to use for CIVO API.
  • region (String) This sets the default region for all resources. If no default region is set, you will need to specify individually in every resource.
  • credentialsFile (string) specify a location for a file containing your civo credentials token
  • token (String) (Deprecated) for legacy reasons the user can still specify the token as an input, but in order to avoid storing that in pulumi state we have deprecated this and will be remove in future versions - don’t use it.