1. Packages
  2. Scaleway
  3. API Docs
  4. DatabasePrivilege
Scaleway v1.15.0 published on Tuesday, Jul 30, 2024 by pulumiverse

scaleway.DatabasePrivilege

Explore with Pulumi AI

scaleway logo
Scaleway v1.15.0 published on Tuesday, Jul 30, 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 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: mainDatabaseUser.name,
        databaseName: mainDatabase.name,
        permission: "all",
    });
    
    import pulumi
    import pulumiverse_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=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 {
    		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:     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 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 = 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 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(mainDatabaseUser.name())
                .databaseName(mainDatabase.name())
                .permission("all")
                .build());
    
        }
    }
    
    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}
      mainDatabaseUser:
        type: scaleway:DatabaseUser
        properties:
          instanceId: ${mainDatabaseInstance.id}
          password: thiZ_is_v&ry_s3cret
          isAdmin: false
      mainDatabasePrivilege:
        type: scaleway:DatabasePrivilege
        properties:
          instanceId: ${mainDatabaseInstance.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

    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.15.0 published on Tuesday, Jul 30, 2024 by pulumiverse