1. Packages
  2. Scaleway
  3. API Docs
  4. DatabasePrivilege
Scaleway v1.10.0 published on Saturday, Jul 1, 2023 by lbrlabs

scaleway.DatabasePrivilege

Explore with Pulumi AI

scaleway logo
Scaleway v1.10.0 published on Saturday, Jul 1, 2023 by lbrlabs

    Create and manage Scaleway RDB database privilege. For more information, see the documentation.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Lbrlabs.PulumiPackage.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var mainDatabaseInstance = new Scaleway.DatabaseInstance("mainDatabaseInstance", new()
        {
            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("mainDatabase", new()
        {
            InstanceId = mainDatabaseInstance.Id,
        });
    
        var mainDatabaseUser = new Scaleway.DatabaseUser("mainDatabaseUser", new()
        {
            InstanceId = mainDatabaseInstance.Id,
            Password = "thiZ_is_v&ry_s3cret",
            IsAdmin = false,
        });
    
        var mainDatabasePrivilege = new Scaleway.DatabasePrivilege("mainDatabasePrivilege", new()
        {
            InstanceId = mainDatabaseInstance.Id,
            UserName = "my-db-user",
            DatabaseName = "my-db-name",
            Permission = "all",
        }, new CustomResourceOptions
        {
            DependsOn = new[]
            {
                mainDatabaseUser,
                mainDatabase,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/lbrlabs/pulumi-scaleway/sdk/go/scaleway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		mainDatabaseInstance, err := scaleway.NewDatabaseInstance(ctx, "mainDatabaseInstance", &scaleway.DatabaseInstanceArgs{
    			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, "mainDatabase", &scaleway.DatabaseArgs{
    			InstanceId: mainDatabaseInstance.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainDatabaseUser, err := scaleway.NewDatabaseUser(ctx, "mainDatabaseUser", &scaleway.DatabaseUserArgs{
    			InstanceId: mainDatabaseInstance.ID(),
    			Password:   pulumi.String("thiZ_is_v&ry_s3cret"),
    			IsAdmin:    pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = scaleway.NewDatabasePrivilege(ctx, "mainDatabasePrivilege", &scaleway.DatabasePrivilegeArgs{
    			InstanceId:   mainDatabaseInstance.ID(),
    			UserName:     pulumi.String("my-db-user"),
    			DatabaseName: pulumi.String("my-db-name"),
    			Permission:   pulumi.String("all"),
    		}, pulumi.DependsOn([]pulumi.Resource{
    			mainDatabaseUser,
    			mainDatabase,
    		}))
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 com.pulumi.resources.CustomResourceOptions;
    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 mainDatabaseInstance = new DatabaseInstance("mainDatabaseInstance", DatabaseInstanceArgs.builder()        
                .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(mainDatabaseInstance.id())
                .build());
    
            var mainDatabaseUser = new DatabaseUser("mainDatabaseUser", DatabaseUserArgs.builder()        
                .instanceId(mainDatabaseInstance.id())
                .password("thiZ_is_v&ry_s3cret")
                .isAdmin(false)
                .build());
    
            var mainDatabasePrivilege = new DatabasePrivilege("mainDatabasePrivilege", DatabasePrivilegeArgs.builder()        
                .instanceId(mainDatabaseInstance.id())
                .userName("my-db-user")
                .databaseName("my-db-name")
                .permission("all")
                .build(), CustomResourceOptions.builder()
                    .dependsOn(                
                        mainDatabaseUser,
                        mainDatabase)
                    .build());
    
        }
    }
    
    import pulumi
    import lbrlabs_pulumi_scaleway as scaleway
    
    main_database_instance = scaleway.DatabaseInstance("mainDatabaseInstance",
        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("mainDatabase", instance_id=main_database_instance.id)
    main_database_user = scaleway.DatabaseUser("mainDatabaseUser",
        instance_id=main_database_instance.id,
        password="thiZ_is_v&ry_s3cret",
        is_admin=False)
    main_database_privilege = scaleway.DatabasePrivilege("mainDatabasePrivilege",
        instance_id=main_database_instance.id,
        user_name="my-db-user",
        database_name="my-db-name",
        permission="all",
        opts=pulumi.ResourceOptions(depends_on=[
                main_database_user,
                main_database,
            ]))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@lbrlabs/pulumi-scaleway";
    
    const mainDatabaseInstance = new scaleway.DatabaseInstance("mainDatabaseInstance", {
        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("mainDatabase", {instanceId: mainDatabaseInstance.id});
    const mainDatabaseUser = new scaleway.DatabaseUser("mainDatabaseUser", {
        instanceId: mainDatabaseInstance.id,
        password: "thiZ_is_v&ry_s3cret",
        isAdmin: false,
    });
    const mainDatabasePrivilege = new scaleway.DatabasePrivilege("mainDatabasePrivilege", {
        instanceId: mainDatabaseInstance.id,
        userName: "my-db-user",
        databaseName: "my-db-name",
        permission: "all",
    }, {
        dependsOn: [
            mainDatabaseUser,
            mainDatabase,
        ],
    });
    
    resources:
      mainDatabaseInstance:
        type: scaleway:DatabaseInstance
        properties:
          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
        properties:
          instanceId: ${mainDatabaseInstance.id}
      mainDatabasePrivilege:
        type: scaleway:DatabasePrivilege
        properties:
          instanceId: ${mainDatabaseInstance.id}
          userName: my-db-user
          databaseName: my-db-name
          permission: all
        options:
          dependson:
            - ${mainDatabaseUser}
            - ${mainDatabase}
      mainDatabaseUser:
        type: scaleway:DatabaseUser
        properties:
          instanceId: ${mainDatabaseInstance.id}
          password: thiZ_is_v&ry_s3cret
          isAdmin: false
    

    Create DatabasePrivilege Resource

    new DatabasePrivilege(name: string, args: DatabasePrivilegeArgs, opts?: CustomResourceOptions);
    @overload
    def DatabasePrivilege(resource_name: 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)
    @overload
    def DatabasePrivilege(resource_name: str,
                          args: DatabasePrivilegeArgs,
                          opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

    The DatabasePrivilege resource accepts the following input properties:

    DatabaseName string

    Name of the database (e.g. my-db-name).

    InstanceId string

    UUID of the rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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 rdb 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
    

    Package Details

    Repository
    scaleway lbrlabs/pulumi-scaleway
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the scaleway Terraform Provider.

    scaleway logo
    Scaleway v1.10.0 published on Saturday, Jul 1, 2023 by lbrlabs