1. Packages
  2. OVH
  3. API Docs
  4. CloudProjectDatabase
  5. DatabaseInstance
OVHCloud v2.1.1 published on Thursday, Apr 10, 2025 by OVHcloud

ovh.CloudProjectDatabase.DatabaseInstance

Explore with Pulumi AI

Creates a database for a database cluster associated with a public cloud project.

With this resource you can create a database for the following database engine:

  • mysql
  • postgresql

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as ovh from "@ovhcloud/pulumi-ovh";
import * as ovh from "@pulumi/ovh";

const db = ovh.CloudProjectDatabase.getDatabase({
    serviceName: "XXXX",
    engine: "YYYY",
    id: "ZZZZ",
});
const database = new ovh.cloudprojectdatabase.DatabaseInstance("database", {
    serviceName: db.then(db => db.serviceName),
    engine: db.then(db => db.engine),
    clusterId: db.then(db => db.id),
});
Copy
import pulumi
import pulumi_ovh as ovh

db = ovh.CloudProjectDatabase.get_database(service_name="XXXX",
    engine="YYYY",
    id="ZZZZ")
database = ovh.cloud_project_database.DatabaseInstance("database",
    service_name=db.service_name,
    engine=db.engine,
    cluster_id=db.id)
Copy
package main

import (
	"github.com/ovh/pulumi-ovh/sdk/v2/go/ovh/cloudprojectdatabase"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		db, err := cloudprojectdatabase.GetDatabase(ctx, &cloudprojectdatabase.GetDatabaseArgs{
			ServiceName: "XXXX",
			Engine:      "YYYY",
			Id:          "ZZZZ",
		}, nil)
		if err != nil {
			return err
		}
		_, err = cloudprojectdatabase.NewDatabaseInstance(ctx, "database", &cloudprojectdatabase.DatabaseInstanceArgs{
			ServiceName: pulumi.String(db.ServiceName),
			Engine:      pulumi.String(db.Engine),
			ClusterId:   pulumi.String(db.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ovh = Pulumi.Ovh;

return await Deployment.RunAsync(() => 
{
    var db = Ovh.CloudProjectDatabase.GetDatabase.Invoke(new()
    {
        ServiceName = "XXXX",
        Engine = "YYYY",
        Id = "ZZZZ",
    });

    var database = new Ovh.CloudProjectDatabase.DatabaseInstance("database", new()
    {
        ServiceName = db.Apply(getDatabaseResult => getDatabaseResult.ServiceName),
        Engine = db.Apply(getDatabaseResult => getDatabaseResult.Engine),
        ClusterId = db.Apply(getDatabaseResult => getDatabaseResult.Id),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ovh.CloudProjectDatabase.CloudProjectDatabaseFunctions;
import com.pulumi.ovh.CloudProjectDatabase.inputs.GetDatabaseArgs;
import com.ovhcloud.pulumi.ovh.CloudProjectDatabase.DatabaseInstance;
import com.ovhcloud.pulumi.ovh.CloudProjectDatabase.DatabaseInstanceArgs;
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) {
        final var db = CloudProjectDatabaseFunctions.getDatabase(GetDatabaseArgs.builder()
            .serviceName("XXXX")
            .engine("YYYY")
            .id("ZZZZ")
            .build());

        var database = new DatabaseInstance("database", DatabaseInstanceArgs.builder()
            .serviceName(db.serviceName())
            .engine(db.engine())
            .clusterId(db.id())
            .build());

    }
}
Copy
resources:
  database:
    type: ovh:CloudProjectDatabase:DatabaseInstance
    properties:
      serviceName: ${db.serviceName}
      engine: ${db.engine}
      clusterId: ${db.id}
variables:
  db:
    fn::invoke:
      function: ovh:CloudProjectDatabase:getDatabase
      arguments:
        serviceName: XXXX
        engine: YYYY
        id: ZZZZ
Copy

Create DatabaseInstance Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new DatabaseInstance(name: string, args: DatabaseInstanceArgs, opts?: CustomResourceOptions);
@overload
def DatabaseInstance(resource_name: str,
                     args: DatabaseInstanceArgs,
                     opts: Optional[ResourceOptions] = None)

@overload
def DatabaseInstance(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     cluster_id: Optional[str] = None,
                     engine: Optional[str] = None,
                     service_name: Optional[str] = None,
                     name: Optional[str] = None)
func NewDatabaseInstance(ctx *Context, name string, args DatabaseInstanceArgs, opts ...ResourceOption) (*DatabaseInstance, error)
public DatabaseInstance(string name, DatabaseInstanceArgs args, CustomResourceOptions? opts = null)
public DatabaseInstance(String name, DatabaseInstanceArgs args)
public DatabaseInstance(String name, DatabaseInstanceArgs args, CustomResourceOptions options)
type: ovh:CloudProjectDatabase:DatabaseInstance
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DatabaseInstanceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DatabaseInstanceArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DatabaseInstanceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DatabaseInstanceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DatabaseInstanceArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var databaseInstanceResource = new Ovh.CloudProjectDatabase.DatabaseInstance("databaseInstanceResource", new()
{
    ClusterId = "string",
    Engine = "string",
    ServiceName = "string",
    Name = "string",
});
Copy
example, err := CloudProjectDatabase.NewDatabaseInstance(ctx, "databaseInstanceResource", &CloudProjectDatabase.DatabaseInstanceArgs{
	ClusterId:   pulumi.String("string"),
	Engine:      pulumi.String("string"),
	ServiceName: pulumi.String("string"),
	Name:        pulumi.String("string"),
})
Copy
var databaseInstanceResource = new DatabaseInstance("databaseInstanceResource", DatabaseInstanceArgs.builder()
    .clusterId("string")
    .engine("string")
    .serviceName("string")
    .name("string")
    .build());
Copy
database_instance_resource = ovh.cloud_project_database.DatabaseInstance("databaseInstanceResource",
    cluster_id="string",
    engine="string",
    service_name="string",
    name="string")
Copy
const databaseInstanceResource = new ovh.cloudprojectdatabase.DatabaseInstance("databaseInstanceResource", {
    clusterId: "string",
    engine: "string",
    serviceName: "string",
    name: "string",
});
Copy
type: ovh:CloudProjectDatabase:DatabaseInstance
properties:
    clusterId: string
    engine: string
    name: string
    serviceName: string
Copy

DatabaseInstance Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The DatabaseInstance resource accepts the following input properties:

ClusterId
This property is required.
Changes to this property will trigger replacement.
string
Cluster ID.
Engine
This property is required.
Changes to this property will trigger replacement.
string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
ServiceName
This property is required.
Changes to this property will trigger replacement.
string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
Name Changes to this property will trigger replacement. string
Name of the database.
ClusterId
This property is required.
Changes to this property will trigger replacement.
string
Cluster ID.
Engine
This property is required.
Changes to this property will trigger replacement.
string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
ServiceName
This property is required.
Changes to this property will trigger replacement.
string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
Name Changes to this property will trigger replacement. string
Name of the database.
clusterId
This property is required.
Changes to this property will trigger replacement.
String
Cluster ID.
engine
This property is required.
Changes to this property will trigger replacement.
String
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
serviceName
This property is required.
Changes to this property will trigger replacement.
String
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
name Changes to this property will trigger replacement. String
Name of the database.
clusterId
This property is required.
Changes to this property will trigger replacement.
string
Cluster ID.
engine
This property is required.
Changes to this property will trigger replacement.
string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
serviceName
This property is required.
Changes to this property will trigger replacement.
string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
name Changes to this property will trigger replacement. string
Name of the database.
cluster_id
This property is required.
Changes to this property will trigger replacement.
str
Cluster ID.
engine
This property is required.
Changes to this property will trigger replacement.
str
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
service_name
This property is required.
Changes to this property will trigger replacement.
str
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
name Changes to this property will trigger replacement. str
Name of the database.
clusterId
This property is required.
Changes to this property will trigger replacement.
String
Cluster ID.
engine
This property is required.
Changes to this property will trigger replacement.
String
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
serviceName
This property is required.
Changes to this property will trigger replacement.
String
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
name Changes to this property will trigger replacement. String
Name of the database.

Outputs

All input properties are implicitly available as output properties. Additionally, the DatabaseInstance resource produces the following output properties:

Default bool
Defines if the database has been created by default.
Id string
The provider-assigned unique ID for this managed resource.
Default bool
Defines if the database has been created by default.
Id string
The provider-assigned unique ID for this managed resource.
default_ Boolean
Defines if the database has been created by default.
id String
The provider-assigned unique ID for this managed resource.
default boolean
Defines if the database has been created by default.
id string
The provider-assigned unique ID for this managed resource.
default bool
Defines if the database has been created by default.
id str
The provider-assigned unique ID for this managed resource.
default Boolean
Defines if the database has been created by default.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing DatabaseInstance Resource

Get an existing DatabaseInstance resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DatabaseInstanceState, opts?: CustomResourceOptions): DatabaseInstance
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cluster_id: Optional[str] = None,
        default: Optional[bool] = None,
        engine: Optional[str] = None,
        name: Optional[str] = None,
        service_name: Optional[str] = None) -> DatabaseInstance
func GetDatabaseInstance(ctx *Context, name string, id IDInput, state *DatabaseInstanceState, opts ...ResourceOption) (*DatabaseInstance, error)
public static DatabaseInstance Get(string name, Input<string> id, DatabaseInstanceState? state, CustomResourceOptions? opts = null)
public static DatabaseInstance get(String name, Output<String> id, DatabaseInstanceState state, CustomResourceOptions options)
resources:  _:    type: ovh:CloudProjectDatabase:DatabaseInstance    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ClusterId Changes to this property will trigger replacement. string
Cluster ID.
Default bool
Defines if the database has been created by default.
Engine Changes to this property will trigger replacement. string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
Name Changes to this property will trigger replacement. string
Name of the database.
ServiceName Changes to this property will trigger replacement. string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
ClusterId Changes to this property will trigger replacement. string
Cluster ID.
Default bool
Defines if the database has been created by default.
Engine Changes to this property will trigger replacement. string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
Name Changes to this property will trigger replacement. string
Name of the database.
ServiceName Changes to this property will trigger replacement. string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
clusterId Changes to this property will trigger replacement. String
Cluster ID.
default_ Boolean
Defines if the database has been created by default.
engine Changes to this property will trigger replacement. String
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
name Changes to this property will trigger replacement. String
Name of the database.
serviceName Changes to this property will trigger replacement. String
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
clusterId Changes to this property will trigger replacement. string
Cluster ID.
default boolean
Defines if the database has been created by default.
engine Changes to this property will trigger replacement. string
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
name Changes to this property will trigger replacement. string
Name of the database.
serviceName Changes to this property will trigger replacement. string
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
cluster_id Changes to this property will trigger replacement. str
Cluster ID.
default bool
Defines if the database has been created by default.
engine Changes to this property will trigger replacement. str
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
name Changes to this property will trigger replacement. str
Name of the database.
service_name Changes to this property will trigger replacement. str
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
clusterId Changes to this property will trigger replacement. String
Cluster ID.
default Boolean
Defines if the database has been created by default.
engine Changes to this property will trigger replacement. String
The engine of the database cluster you want to add. You can find the complete list of available engine in the public documentation. Available engines:
name Changes to this property will trigger replacement. String
Name of the database.
serviceName Changes to this property will trigger replacement. String
The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.

Import

OVHcloud Managed database clusters databases can be imported using the service_name, engine, cluster_id and id of the database, separated by “/” E.g.,

bash

$ pulumi import ovh:CloudProjectDatabase/databaseInstance:DatabaseInstance my_database service_name/engine/cluster_id/id
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
ovh ovh/pulumi-ovh
License
Apache-2.0
Notes
This Pulumi package is based on the ovh Terraform Provider.