1. Packages
  2. OVH
  3. API Docs
  4. CloudProjectDatabase
  5. DatabaseInstance
OVHCloud v0.40.1 published on Tuesday, Mar 26, 2024 by OVHcloud

ovh.CloudProjectDatabase.DatabaseInstance

Explore with Pulumi AI

ovh logo
OVHCloud v0.40.1 published on Tuesday, Mar 26, 2024 by OVHcloud

    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),
    });
    
    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)
    
    package main
    
    import (
    	"github.com/ovh/pulumi-ovh/sdk/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
    	})
    }
    
    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),
        });
    
    });
    
    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.pulumi.ovh.CloudProjectDatabase.DatabaseInstance;
    import com.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.applyValue(getDatabaseResult -> getDatabaseResult.serviceName()))
                .engine(db.applyValue(getDatabaseResult -> getDatabaseResult.engine()))
                .clusterId(db.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
        }
    }
    
    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
    

    Create DatabaseInstance Resource

    new DatabaseInstance(name: string, args: DatabaseInstanceArgs, opts?: CustomResourceOptions);
    @overload
    def DatabaseInstance(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         cluster_id: Optional[str] = None,
                         engine: Optional[str] = None,
                         name: Optional[str] = None,
                         service_name: Optional[str] = None)
    @overload
    def DatabaseInstance(resource_name: str,
                         args: DatabaseInstanceArgs,
                         opts: Optional[ResourceOptions] = 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.
    
    
    name string
    The unique name of the resource.
    args DatabaseInstanceArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args DatabaseInstanceArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabaseInstanceArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabaseInstanceArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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

    The DatabaseInstance resource accepts the following input properties:

    ClusterId string
    Cluster ID.
    Engine 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 string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    Name string
    Name of the database.
    ClusterId string
    Cluster ID.
    Engine 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 string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    Name string
    Name of the database.
    clusterId String
    Cluster ID.
    engine 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 String
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    name String
    Name of the database.
    clusterId string
    Cluster ID.
    engine 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 string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    name string
    Name of the database.
    cluster_id str
    Cluster ID.
    engine 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 str
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    name str
    Name of the database.
    clusterId String
    Cluster ID.
    engine 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 String
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    name 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    Cluster ID.
    Default bool
    Defines if the database has been created by default.
    Engine 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 string
    Name of the database.
    ServiceName string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    ClusterId string
    Cluster ID.
    Default bool
    Defines if the database has been created by default.
    Engine 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 string
    Name of the database.
    ServiceName string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    clusterId String
    Cluster ID.
    default_ Boolean
    Defines if the database has been created by default.
    engine 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 String
    Name of the database.
    serviceName String
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    clusterId string
    Cluster ID.
    default boolean
    Defines if the database has been created by default.
    engine 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 string
    Name of the database.
    serviceName string
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    cluster_id str
    Cluster ID.
    default bool
    Defines if the database has been created by default.
    engine 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 str
    Name of the database.
    service_name str
    The id of the public cloud project. If omitted, the OVH_CLOUD_PROJECT_SERVICE environment variable is used.
    clusterId String
    Cluster ID.
    default Boolean
    Defines if the database has been created by default.
    engine 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 String
    Name of the database.
    serviceName 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
    

    Package Details

    Repository
    ovh ovh/pulumi-ovh
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the ovh Terraform Provider.
    ovh logo
    OVHCloud v0.40.1 published on Tuesday, Mar 26, 2024 by OVHcloud