1. Packages
  2. MSSQL
  3. API Docs
  4. Database
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

mssql.Database

Explore with Pulumi AI

Manages single database.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as mssql from "@pulumiverse/mssql";

const example = new mssql.Database("example", {collation: "SQL_Latin1_General_CP1_CS_AS"});
Copy
import pulumi
import pulumiverse_mssql as mssql

example = mssql.Database("example", collation="SQL_Latin1_General_CP1_CS_AS")
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := mssql.NewDatabase(ctx, "example", &mssql.DatabaseArgs{
			Collation: pulumi.String("SQL_Latin1_General_CP1_CS_AS"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mssql = Pulumiverse.Mssql;

return await Deployment.RunAsync(() => 
{
    var example = new Mssql.Database("example", new()
    {
        Collation = "SQL_Latin1_General_CP1_CS_AS",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mssql.Database;
import com.pulumi.mssql.DatabaseArgs;
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) {
        var example = new Database("example", DatabaseArgs.builder()
            .collation("SQL_Latin1_General_CP1_CS_AS")
            .build());

    }
}
Copy
resources:
  example:
    type: mssql:Database
    properties:
      collation: SQL_Latin1_General_CP1_CS_AS
Copy

Create Database Resource

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

Constructor syntax

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

@overload
def Database(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             collation: Optional[str] = None,
             name: Optional[str] = None)
func NewDatabase(ctx *Context, name string, args *DatabaseArgs, opts ...ResourceOption) (*Database, error)
public Database(string name, DatabaseArgs? args = null, CustomResourceOptions? opts = null)
public Database(String name, DatabaseArgs args)
public Database(String name, DatabaseArgs args, CustomResourceOptions options)
type: mssql:Database
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 DatabaseArgs
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 DatabaseArgs
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 DatabaseArgs
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 DatabaseArgs
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. DatabaseArgs
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 databaseResource = new Mssql.Database("databaseResource", new()
{
    Collation = "string",
    Name = "string",
});
Copy
example, err := mssql.NewDatabase(ctx, "databaseResource", &mssql.DatabaseArgs{
	Collation: pulumi.String("string"),
	Name:      pulumi.String("string"),
})
Copy
var databaseResource = new Database("databaseResource", DatabaseArgs.builder()
    .collation("string")
    .name("string")
    .build());
Copy
database_resource = mssql.Database("databaseResource",
    collation="string",
    name="string")
Copy
const databaseResource = new mssql.Database("databaseResource", {
    collation: "string",
    name: "string",
});
Copy
type: mssql:Database
properties:
    collation: string
    name: string
Copy

Database 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 Database resource accepts the following input properties:

Collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
Name string
Database name. Must follow Regular Identifiers rules.
Collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
Name string
Database name. Must follow Regular Identifiers rules.
collation String
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name String
Database name. Must follow Regular Identifiers rules.
collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name string
Database name. Must follow Regular Identifiers rules.
collation str
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name str
Database name. Must follow Regular Identifiers rules.
collation String
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name String
Database name. Must follow Regular Identifiers rules.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Database Resource

Get an existing Database 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?: DatabaseState, opts?: CustomResourceOptions): Database
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        collation: Optional[str] = None,
        name: Optional[str] = None) -> Database
func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)
resources:  _:    type: mssql:Database    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:
Collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
Name string
Database name. Must follow Regular Identifiers rules.
Collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
Name string
Database name. Must follow Regular Identifiers rules.
collation String
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name String
Database name. Must follow Regular Identifiers rules.
collation string
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name string
Database name. Must follow Regular Identifiers rules.
collation str
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name str
Database name. Must follow Regular Identifiers rules.
collation String
Default collation name. Can be either a Windows collation name or a SQL collation name. Defaults to SQL Server instance's default collation.
name String
Database name. Must follow Regular Identifiers rules.

Import

import using database ID - can be retrieved using SELECT DB_ID('<db_name>')

$ pulumi import mssql:index/database:Database example 12
Copy

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

Package Details

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