1. Packages
  2. Scaleway
  3. API Docs
  4. DatabasePrivilege
Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse

scaleway.DatabasePrivilege

Explore with Pulumi AI

scaleway logo
Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse

    Create and manage Scaleway database privileges. For more information refer to the API documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const main = new scaleway.DatabaseInstance("main", {
        name: "rdb",
        nodeType: "DB-DEV-S",
        engine: "PostgreSQL-11",
        isHaCluster: true,
        disableBackup: true,
        userName: "my_initial_user",
        password: "thiZ_is_v&ry_s3cret",
    });
    const mainDatabase = new scaleway.Database("main", {
        instanceId: main.id,
        name: "database",
    });
    const mainDatabaseUser = new scaleway.DatabaseUser("main", {
        instanceId: main.id,
        name: "my-db-user",
        password: "thiZ_is_v&ry_s3cret",
        isAdmin: false,
    });
    const mainDatabasePrivilege = new scaleway.DatabasePrivilege("main", {
        instanceId: main.id,
        userName: mainDatabaseUser.name,
        databaseName: mainDatabase.name,
        permission: "all",
    });
    
    import pulumi
    import pulumiverse_scaleway as scaleway
    
    main = scaleway.DatabaseInstance("main",
        name="rdb",
        node_type="DB-DEV-S",
        engine="PostgreSQL-11",
        is_ha_cluster=True,
        disable_backup=True,
        user_name="my_initial_user",
        password="thiZ_is_v&ry_s3cret")
    main_database = scaleway.Database("main",
        instance_id=main.id,
        name="database")
    main_database_user = scaleway.DatabaseUser("main",
        instance_id=main.id,
        name="my-db-user",
        password="thiZ_is_v&ry_s3cret",
        is_admin=False)
    main_database_privilege = scaleway.DatabasePrivilege("main",
        instance_id=main.id,
        user_name=main_database_user.name,
        database_name=main_database.name,
        permission="all")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		main, err := scaleway.NewDatabaseInstance(ctx, "main", &scaleway.DatabaseInstanceArgs{
    			Name:          pulumi.String("rdb"),
    			NodeType:      pulumi.String("DB-DEV-S"),
    			Engine:        pulumi.String("PostgreSQL-11"),
    			IsHaCluster:   pulumi.Bool(true),
    			DisableBackup: pulumi.Bool(true),
    			UserName:      pulumi.String("my_initial_user"),
    			Password:      pulumi.String("thiZ_is_v&ry_s3cret"),
    		})
    		if err != nil {
    			return err
    		}
    		mainDatabase, err := scaleway.NewDatabase(ctx, "main", &scaleway.DatabaseArgs{
    			InstanceId: main.ID(),
    			Name:       pulumi.String("database"),
    		})
    		if err != nil {
    			return err
    		}
    		mainDatabaseUser, err := scaleway.NewDatabaseUser(ctx, "main", &scaleway.DatabaseUserArgs{
    			InstanceId: main.ID(),
    			Name:       pulumi.String("my-db-user"),
    			Password:   pulumi.String("thiZ_is_v&ry_s3cret"),
    			IsAdmin:    pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = scaleway.NewDatabasePrivilege(ctx, "main", &scaleway.DatabasePrivilegeArgs{
    			InstanceId:   main.ID(),
    			UserName:     mainDatabaseUser.Name,
    			DatabaseName: mainDatabase.Name,
    			Permission:   pulumi.String("all"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var main = new Scaleway.DatabaseInstance("main", new()
        {
            Name = "rdb",
            NodeType = "DB-DEV-S",
            Engine = "PostgreSQL-11",
            IsHaCluster = true,
            DisableBackup = true,
            UserName = "my_initial_user",
            Password = "thiZ_is_v&ry_s3cret",
        });
    
        var mainDatabase = new Scaleway.Database("main", new()
        {
            InstanceId = main.Id,
            Name = "database",
        });
    
        var mainDatabaseUser = new Scaleway.DatabaseUser("main", new()
        {
            InstanceId = main.Id,
            Name = "my-db-user",
            Password = "thiZ_is_v&ry_s3cret",
            IsAdmin = false,
        });
    
        var mainDatabasePrivilege = new Scaleway.DatabasePrivilege("main", new()
        {
            InstanceId = main.Id,
            UserName = mainDatabaseUser.Name,
            DatabaseName = mainDatabase.Name,
            Permission = "all",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.scaleway.DatabaseInstance;
    import com.pulumi.scaleway.DatabaseInstanceArgs;
    import com.pulumi.scaleway.Database;
    import com.pulumi.scaleway.DatabaseArgs;
    import com.pulumi.scaleway.DatabaseUser;
    import com.pulumi.scaleway.DatabaseUserArgs;
    import com.pulumi.scaleway.DatabasePrivilege;
    import com.pulumi.scaleway.DatabasePrivilegeArgs;
    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 main = new DatabaseInstance("main", DatabaseInstanceArgs.builder()
                .name("rdb")
                .nodeType("DB-DEV-S")
                .engine("PostgreSQL-11")
                .isHaCluster(true)
                .disableBackup(true)
                .userName("my_initial_user")
                .password("thiZ_is_v&ry_s3cret")
                .build());
    
            var mainDatabase = new Database("mainDatabase", DatabaseArgs.builder()
                .instanceId(main.id())
                .name("database")
                .build());
    
            var mainDatabaseUser = new DatabaseUser("mainDatabaseUser", DatabaseUserArgs.builder()
                .instanceId(main.id())
                .name("my-db-user")
                .password("thiZ_is_v&ry_s3cret")
                .isAdmin(false)
                .build());
    
            var mainDatabasePrivilege = new DatabasePrivilege("mainDatabasePrivilege", DatabasePrivilegeArgs.builder()
                .instanceId(main.id())
                .userName(mainDatabaseUser.name())
                .databaseName(mainDatabase.name())
                .permission("all")
                .build());
    
        }
    }
    
    resources:
      main:
        type: scaleway:DatabaseInstance
        properties:
          name: rdb
          nodeType: DB-DEV-S
          engine: PostgreSQL-11
          isHaCluster: true
          disableBackup: true
          userName: my_initial_user
          password: thiZ_is_v&ry_s3cret
      mainDatabase:
        type: scaleway:Database
        name: main
        properties:
          instanceId: ${main.id}
          name: database
      mainDatabaseUser:
        type: scaleway:DatabaseUser
        name: main
        properties:
          instanceId: ${main.id}
          name: my-db-user
          password: thiZ_is_v&ry_s3cret
          isAdmin: false
      mainDatabasePrivilege:
        type: scaleway:DatabasePrivilege
        name: main
        properties:
          instanceId: ${main.id}
          userName: ${mainDatabaseUser.name}
          databaseName: ${mainDatabase.name}
          permission: all
    

    Create DatabasePrivilege Resource

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

    Constructor syntax

    new DatabasePrivilege(name: string, args: DatabasePrivilegeArgs, opts?: CustomResourceOptions);
    @overload
    def DatabasePrivilege(resource_name: str,
                          args: DatabasePrivilegeArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def DatabasePrivilege(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          database_name: Optional[str] = None,
                          instance_id: Optional[str] = None,
                          permission: Optional[str] = None,
                          user_name: Optional[str] = None,
                          region: Optional[str] = None)
    func NewDatabasePrivilege(ctx *Context, name string, args DatabasePrivilegeArgs, opts ...ResourceOption) (*DatabasePrivilege, error)
    public DatabasePrivilege(string name, DatabasePrivilegeArgs args, CustomResourceOptions? opts = null)
    public DatabasePrivilege(String name, DatabasePrivilegeArgs args)
    public DatabasePrivilege(String name, DatabasePrivilegeArgs args, CustomResourceOptions options)
    
    type: scaleway:DatabasePrivilege
    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 DatabasePrivilegeArgs
    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 DatabasePrivilegeArgs
    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 DatabasePrivilegeArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabasePrivilegeArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabasePrivilegeArgs
    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 databasePrivilegeResource = new Scaleway.DatabasePrivilege("databasePrivilegeResource", new()
    {
        DatabaseName = "string",
        InstanceId = "string",
        Permission = "string",
        UserName = "string",
        Region = "string",
    });
    
    example, err := scaleway.NewDatabasePrivilege(ctx, "databasePrivilegeResource", &scaleway.DatabasePrivilegeArgs{
    	DatabaseName: pulumi.String("string"),
    	InstanceId:   pulumi.String("string"),
    	Permission:   pulumi.String("string"),
    	UserName:     pulumi.String("string"),
    	Region:       pulumi.String("string"),
    })
    
    var databasePrivilegeResource = new DatabasePrivilege("databasePrivilegeResource", DatabasePrivilegeArgs.builder()
        .databaseName("string")
        .instanceId("string")
        .permission("string")
        .userName("string")
        .region("string")
        .build());
    
    database_privilege_resource = scaleway.DatabasePrivilege("databasePrivilegeResource",
        database_name="string",
        instance_id="string",
        permission="string",
        user_name="string",
        region="string")
    
    const databasePrivilegeResource = new scaleway.DatabasePrivilege("databasePrivilegeResource", {
        databaseName: "string",
        instanceId: "string",
        permission: "string",
        userName: "string",
        region: "string",
    });
    
    type: scaleway:DatabasePrivilege
    properties:
        databaseName: string
        instanceId: string
        permission: string
        region: string
        userName: string
    

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

    DatabaseName string
    Name of the database (e.g. my-db-name).
    InstanceId string
    UUID of the Database Instance.
    Permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    UserName string
    Name of the user (e.g. my-db-user).
    Region string
    region) The region in which the resource exists.
    DatabaseName string
    Name of the database (e.g. my-db-name).
    InstanceId string
    UUID of the Database Instance.
    Permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    UserName string
    Name of the user (e.g. my-db-user).
    Region string
    region) The region in which the resource exists.
    databaseName String
    Name of the database (e.g. my-db-name).
    instanceId String
    UUID of the Database Instance.
    permission String
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    userName String
    Name of the user (e.g. my-db-user).
    region String
    region) The region in which the resource exists.
    databaseName string
    Name of the database (e.g. my-db-name).
    instanceId string
    UUID of the Database Instance.
    permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    userName string
    Name of the user (e.g. my-db-user).
    region string
    region) The region in which the resource exists.
    database_name str
    Name of the database (e.g. my-db-name).
    instance_id str
    UUID of the Database Instance.
    permission str
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    user_name str
    Name of the user (e.g. my-db-user).
    region str
    region) The region in which the resource exists.
    databaseName String
    Name of the database (e.g. my-db-name).
    instanceId String
    UUID of the Database Instance.
    permission String
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    userName String
    Name of the user (e.g. my-db-user).
    region String
    region) The region in which the resource exists.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DatabasePrivilege 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 DatabasePrivilege Resource

    Get an existing DatabasePrivilege 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?: DatabasePrivilegeState, opts?: CustomResourceOptions): DatabasePrivilege
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            database_name: Optional[str] = None,
            instance_id: Optional[str] = None,
            permission: Optional[str] = None,
            region: Optional[str] = None,
            user_name: Optional[str] = None) -> DatabasePrivilege
    func GetDatabasePrivilege(ctx *Context, name string, id IDInput, state *DatabasePrivilegeState, opts ...ResourceOption) (*DatabasePrivilege, error)
    public static DatabasePrivilege Get(string name, Input<string> id, DatabasePrivilegeState? state, CustomResourceOptions? opts = null)
    public static DatabasePrivilege get(String name, Output<String> id, DatabasePrivilegeState 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:
    DatabaseName string
    Name of the database (e.g. my-db-name).
    InstanceId string
    UUID of the Database Instance.
    Permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    Region string
    region) The region in which the resource exists.
    UserName string
    Name of the user (e.g. my-db-user).
    DatabaseName string
    Name of the database (e.g. my-db-name).
    InstanceId string
    UUID of the Database Instance.
    Permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    Region string
    region) The region in which the resource exists.
    UserName string
    Name of the user (e.g. my-db-user).
    databaseName String
    Name of the database (e.g. my-db-name).
    instanceId String
    UUID of the Database Instance.
    permission String
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    region String
    region) The region in which the resource exists.
    userName String
    Name of the user (e.g. my-db-user).
    databaseName string
    Name of the database (e.g. my-db-name).
    instanceId string
    UUID of the Database Instance.
    permission string
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    region string
    region) The region in which the resource exists.
    userName string
    Name of the user (e.g. my-db-user).
    database_name str
    Name of the database (e.g. my-db-name).
    instance_id str
    UUID of the Database Instance.
    permission str
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    region str
    region) The region in which the resource exists.
    user_name str
    Name of the user (e.g. my-db-user).
    databaseName String
    Name of the database (e.g. my-db-name).
    instanceId String
    UUID of the Database Instance.
    permission String
    Permission to set. Valid values are readonly, readwrite, all, custom and none.
    region String
    region) The region in which the resource exists.
    userName String
    Name of the user (e.g. my-db-user).

    Import

    The user privileges can be imported using the {region}/{instance_id}/{database_name}/{user_name}, e.g.

    bash

    $ pulumi import scaleway:index/databasePrivilege:DatabasePrivilege o fr-par/11111111-1111-1111-1111-111111111111/database_name/foo
    

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

    Package Details

    Repository
    scaleway pulumiverse/pulumi-scaleway
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the scaleway Terraform Provider.
    scaleway logo
    Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse