1. Packages
  2. Neon Provider
  3. API Docs
  4. Database
neon 0.9.0 published on Tuesday, May 6, 2025 by kislerdm

neon.Database

Explore with Pulumi AI

neon logo
neon 0.9.0 published on Tuesday, May 6, 2025 by kislerdm

    Project Database. See details: https://neon.tech/docs/manage/databases/

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as neon from "@pulumi/neon";
    
    const exampleProject = new neon.Project("exampleProject", {});
    const exampleBranch = new neon.Branch("exampleBranch", {projectId: exampleProject.id});
    const exampleRole = new neon.Role("exampleRole", {
        projectId: exampleProject.id,
        branchId: exampleBranch.id,
    });
    const exampleDatabase = new neon.Database("exampleDatabase", {
        projectId: exampleProject.id,
        branchId: exampleBranch.id,
        ownerName: exampleRole.name,
    });
    
    import pulumi
    import pulumi_neon as neon
    
    example_project = neon.Project("exampleProject")
    example_branch = neon.Branch("exampleBranch", project_id=example_project.id)
    example_role = neon.Role("exampleRole",
        project_id=example_project.id,
        branch_id=example_branch.id)
    example_database = neon.Database("exampleDatabase",
        project_id=example_project.id,
        branch_id=example_branch.id,
        owner_name=example_role.name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/neon/neon"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := neon.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleBranch, err := neon.NewBranch(ctx, "exampleBranch", &neon.BranchArgs{
    			ProjectId: exampleProject.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		exampleRole, err := neon.NewRole(ctx, "exampleRole", &neon.RoleArgs{
    			ProjectId: exampleProject.ID(),
    			BranchId:  exampleBranch.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = neon.NewDatabase(ctx, "exampleDatabase", &neon.DatabaseArgs{
    			ProjectId: exampleProject.ID(),
    			BranchId:  exampleBranch.ID(),
    			OwnerName: exampleRole.Name,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Neon = Pulumi.Neon;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new Neon.Project("exampleProject");
    
        var exampleBranch = new Neon.Branch("exampleBranch", new()
        {
            ProjectId = exampleProject.Id,
        });
    
        var exampleRole = new Neon.Role("exampleRole", new()
        {
            ProjectId = exampleProject.Id,
            BranchId = exampleBranch.Id,
        });
    
        var exampleDatabase = new Neon.Database("exampleDatabase", new()
        {
            ProjectId = exampleProject.Id,
            BranchId = exampleBranch.Id,
            OwnerName = exampleRole.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.neon.Project;
    import com.pulumi.neon.Branch;
    import com.pulumi.neon.BranchArgs;
    import com.pulumi.neon.Role;
    import com.pulumi.neon.RoleArgs;
    import com.pulumi.neon.Database;
    import com.pulumi.neon.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 exampleProject = new Project("exampleProject");
    
            var exampleBranch = new Branch("exampleBranch", BranchArgs.builder()
                .projectId(exampleProject.id())
                .build());
    
            var exampleRole = new Role("exampleRole", RoleArgs.builder()
                .projectId(exampleProject.id())
                .branchId(exampleBranch.id())
                .build());
    
            var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
                .projectId(exampleProject.id())
                .branchId(exampleBranch.id())
                .ownerName(exampleRole.name())
                .build());
    
        }
    }
    
    resources:
      exampleProject:
        type: neon:Project
      exampleBranch:
        type: neon:Branch
        properties:
          projectId: ${exampleProject.id}
      exampleRole:
        type: neon:Role
        properties:
          projectId: ${exampleProject.id}
          branchId: ${exampleBranch.id}
      exampleDatabase:
        type: neon:Database
        properties:
          projectId: ${exampleProject.id}
          branchId: ${exampleBranch.id}
          ownerName: ${exampleRole.name}
    

    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: DatabaseArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def Database(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 branch_id: Optional[str] = None,
                 owner_name: Optional[str] = None,
                 project_id: Optional[str] = None,
                 database_id: 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, CustomResourceOptions? opts = null)
    public Database(String name, DatabaseArgs args)
    public Database(String name, DatabaseArgs args, CustomResourceOptions options)
    
    type: neon:Database
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name 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 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 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 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 String
    The unique name of the resource.
    args 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 Neon.Database("databaseResource", new()
    {
        BranchId = "string",
        OwnerName = "string",
        ProjectId = "string",
        DatabaseId = "string",
        Name = "string",
    });
    
    example, err := neon.NewDatabase(ctx, "databaseResource", &neon.DatabaseArgs{
    	BranchId:   pulumi.String("string"),
    	OwnerName:  pulumi.String("string"),
    	ProjectId:  pulumi.String("string"),
    	DatabaseId: pulumi.String("string"),
    	Name:       pulumi.String("string"),
    })
    
    var databaseResource = new Database("databaseResource", DatabaseArgs.builder()
        .branchId("string")
        .ownerName("string")
        .projectId("string")
        .databaseId("string")
        .name("string")
        .build());
    
    database_resource = neon.Database("databaseResource",
        branch_id="string",
        owner_name="string",
        project_id="string",
        database_id="string",
        name="string")
    
    const databaseResource = new neon.Database("databaseResource", {
        branchId: "string",
        ownerName: "string",
        projectId: "string",
        databaseId: "string",
        name: "string",
    });
    
    type: neon:Database
    properties:
        branchId: string
        databaseId: string
        name: string
        ownerName: string
        projectId: string
    

    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:

    BranchId string
    Branch ID.
    OwnerName string
    Role name of the database owner.
    ProjectId string
    Project ID.
    DatabaseId string
    The ID of this resource.
    Name string
    Database name.
    BranchId string
    Branch ID.
    OwnerName string
    Role name of the database owner.
    ProjectId string
    Project ID.
    DatabaseId string
    The ID of this resource.
    Name string
    Database name.
    branchId String
    Branch ID.
    ownerName String
    Role name of the database owner.
    projectId String
    Project ID.
    databaseId String
    The ID of this resource.
    name String
    Database name.
    branchId string
    Branch ID.
    ownerName string
    Role name of the database owner.
    projectId string
    Project ID.
    databaseId string
    The ID of this resource.
    name string
    Database name.
    branch_id str
    Branch ID.
    owner_name str
    Role name of the database owner.
    project_id str
    Project ID.
    database_id str
    The ID of this resource.
    name str
    Database name.
    branchId String
    Branch ID.
    ownerName String
    Role name of the database owner.
    projectId String
    Project ID.
    databaseId String
    The ID of this resource.
    name String
    Database name.

    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,
            branch_id: Optional[str] = None,
            database_id: Optional[str] = None,
            name: Optional[str] = None,
            owner_name: Optional[str] = None,
            project_id: 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: neon:Database    get:      id: ${id}
    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:
    BranchId string
    Branch ID.
    DatabaseId string
    The ID of this resource.
    Name string
    Database name.
    OwnerName string
    Role name of the database owner.
    ProjectId string
    Project ID.
    BranchId string
    Branch ID.
    DatabaseId string
    The ID of this resource.
    Name string
    Database name.
    OwnerName string
    Role name of the database owner.
    ProjectId string
    Project ID.
    branchId String
    Branch ID.
    databaseId String
    The ID of this resource.
    name String
    Database name.
    ownerName String
    Role name of the database owner.
    projectId String
    Project ID.
    branchId string
    Branch ID.
    databaseId string
    The ID of this resource.
    name string
    Database name.
    ownerName string
    Role name of the database owner.
    projectId string
    Project ID.
    branch_id str
    Branch ID.
    database_id str
    The ID of this resource.
    name str
    Database name.
    owner_name str
    Role name of the database owner.
    project_id str
    Project ID.
    branchId String
    Branch ID.
    databaseId String
    The ID of this resource.
    name String
    Database name.
    ownerName String
    Role name of the database owner.
    projectId String
    Project ID.

    Import

    The Neon Database can be imported to the terraform state by the identifier which is composed of the projectID, branchID

    and the Database name. For example, the identifier of the Database myDatabase from the branch br-snowy-mountain-a5jkb18i

    of the project shiny-cell-31746257 is shiny-cell-31746257/br-snowy-mountain-a5jkb18i/myDatabase.

    Import using the import block:

    For example:

    hcl

    import {

    to = neon_database.example

    id = “shiny-cell-31746257/br-snowy-mountain-a5jkb18i/myDatabase”

    }

    Import using the command pulumi import:

    commandline

    $ pulumi import neon:index/database:Database example "shiny-cell-31746257/br-snowy-mountain-a5jkb18i/myDatabase"
    

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

    Package Details

    Repository
    neon kislerdm/terraform-provider-neon
    License
    Notes
    This Pulumi package is based on the neon Terraform Provider.
    neon logo
    neon 0.9.0 published on Tuesday, May 6, 2025 by kislerdm