Install tf2pulumi
(e.g: brew install pulumi/tap/tf2pulumi
or download the binary at https://github.com/pulumi/tf2pulumi)
Install the Pulumi CLI if not present on your client.
Install the OVH plugin with following command:
plugin install resource ovh v0.29.0 --server github://api.github.com/lbrlabs
Create a Pulumi project in the same directory as the Terraform project you'd like to import and create a new Pulumi stack in your favourite language (here used go
)
pulumi new go -f
My demo ovh.tf
is this:
variable "service_name" {
type = string
default = "test"
}
resource "ovh_cloud_project_kube" "example_cluster" {
service_name = var.service_name
name = "example-cluster"
region = "GRA7"
}
resource "ovh_cloud_project_kube_nodepool" "example_nodepool" {
service_name = var.service_name
kube_id = ovh_cloud_project_kube.example_cluster.id
name = "example-nodepool"
flavor_name = "b2-7"
desired_nodes = 1
max_nodes = 2
min_nodes = 0
}
Then run tf2pulumi
which will write a file in the directory that contains the Pulumi project you just created:
tf2pulumi --target-language go
This will create the Pulumi program for you:
package main
import (
"github.com/lbrlabs/pulumi-ovh/sdk/go/ovh/CloudProject"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
serviceName := "test"
if param := cfg.Get("serviceName"); param != "" {
serviceName = param
}
exampleCluster, err := CloudProject.NewKube(ctx, "exampleCluster", &CloudProject.KubeArgs{
ServiceName: pulumi.String(serviceName),
Name: pulumi.String("example-cluster"),
Region: pulumi.String("GRA7"),
})
if err != nil {
return err
}
_, err = CloudProject.NewKubeNodePool(ctx, "exampleNodepool", &CloudProject.KubeNodePoolArgs{
ServiceName: pulumi.String(serviceName),
KubeId: exampleCluster.ID(),
Name: pulumi.String("example-nodepool"),
FlavorName: pulumi.String("b2-7"),
DesiredNodes: pulumi.Int(1),
MaxNodes: pulumi.Int(2),
MinNodes: pulumi.Int(0),
})
if err != nil {
return err
}
return nil
})
}
Party! 🎉