1. Packages
  2. MongoDB Atlas
  3. API Docs
  4. getCustomDbRole
MongoDB Atlas v3.14.2 published on Monday, Mar 18, 2024 by Pulumi

mongodbatlas.getCustomDbRole

Explore with Pulumi AI

mongodbatlas logo
MongoDB Atlas v3.14.2 published on Monday, Mar 18, 2024 by Pulumi

    mongodbatlas.CustomDbRole describe a Custom DB Role. This represents a custom db role.

    NOTE: Groups and projects are synonymous terms. You may find group_id in the official documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as mongodbatlas from "@pulumi/mongodbatlas";
    
    const testRole = new mongodbatlas.CustomDbRole("testRole", {
        projectId: "<PROJECT-ID>",
        roleName: "myCustomRole",
        actions: [
            {
                action: "UPDATE",
                resources: [{
                    collectionName: "",
                    databaseName: "anyDatabase",
                }],
            },
            {
                action: "INSERT",
                resources: [{
                    collectionName: "",
                    databaseName: "anyDatabase",
                }],
            },
        ],
    });
    const test = mongodbatlas.getCustomDbRoleOutput({
        projectId: testRole.projectId,
        roleName: testRole.roleName,
    });
    
    import pulumi
    import pulumi_mongodbatlas as mongodbatlas
    
    test_role = mongodbatlas.CustomDbRole("testRole",
        project_id="<PROJECT-ID>",
        role_name="myCustomRole",
        actions=[
            mongodbatlas.CustomDbRoleActionArgs(
                action="UPDATE",
                resources=[mongodbatlas.CustomDbRoleActionResourceArgs(
                    collection_name="",
                    database_name="anyDatabase",
                )],
            ),
            mongodbatlas.CustomDbRoleActionArgs(
                action="INSERT",
                resources=[mongodbatlas.CustomDbRoleActionResourceArgs(
                    collection_name="",
                    database_name="anyDatabase",
                )],
            ),
        ])
    test = mongodbatlas.get_custom_db_role_output(project_id=test_role.project_id,
        role_name=test_role.role_name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		testRole, err := mongodbatlas.NewCustomDbRole(ctx, "testRole", &mongodbatlas.CustomDbRoleArgs{
    			ProjectId: pulumi.String("<PROJECT-ID>"),
    			RoleName:  pulumi.String("myCustomRole"),
    			Actions: mongodbatlas.CustomDbRoleActionArray{
    				&mongodbatlas.CustomDbRoleActionArgs{
    					Action: pulumi.String("UPDATE"),
    					Resources: mongodbatlas.CustomDbRoleActionResourceArray{
    						&mongodbatlas.CustomDbRoleActionResourceArgs{
    							CollectionName: pulumi.String(""),
    							DatabaseName:   pulumi.String("anyDatabase"),
    						},
    					},
    				},
    				&mongodbatlas.CustomDbRoleActionArgs{
    					Action: pulumi.String("INSERT"),
    					Resources: mongodbatlas.CustomDbRoleActionResourceArray{
    						&mongodbatlas.CustomDbRoleActionResourceArgs{
    							CollectionName: pulumi.String(""),
    							DatabaseName:   pulumi.String("anyDatabase"),
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_ = mongodbatlas.LookupCustomDbRoleOutput(ctx, mongodbatlas.GetCustomDbRoleOutputArgs{
    			ProjectId: testRole.ProjectId,
    			RoleName:  testRole.RoleName,
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mongodbatlas = Pulumi.Mongodbatlas;
    
    return await Deployment.RunAsync(() => 
    {
        var testRole = new Mongodbatlas.CustomDbRole("testRole", new()
        {
            ProjectId = "<PROJECT-ID>",
            RoleName = "myCustomRole",
            Actions = new[]
            {
                new Mongodbatlas.Inputs.CustomDbRoleActionArgs
                {
                    Action = "UPDATE",
                    Resources = new[]
                    {
                        new Mongodbatlas.Inputs.CustomDbRoleActionResourceArgs
                        {
                            CollectionName = "",
                            DatabaseName = "anyDatabase",
                        },
                    },
                },
                new Mongodbatlas.Inputs.CustomDbRoleActionArgs
                {
                    Action = "INSERT",
                    Resources = new[]
                    {
                        new Mongodbatlas.Inputs.CustomDbRoleActionResourceArgs
                        {
                            CollectionName = "",
                            DatabaseName = "anyDatabase",
                        },
                    },
                },
            },
        });
    
        var test = Mongodbatlas.GetCustomDbRole.Invoke(new()
        {
            ProjectId = testRole.ProjectId,
            RoleName = testRole.RoleName,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mongodbatlas.CustomDbRole;
    import com.pulumi.mongodbatlas.CustomDbRoleArgs;
    import com.pulumi.mongodbatlas.inputs.CustomDbRoleActionArgs;
    import com.pulumi.mongodbatlas.MongodbatlasFunctions;
    import com.pulumi.mongodbatlas.inputs.GetCustomDbRoleArgs;
    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 testRole = new CustomDbRole("testRole", CustomDbRoleArgs.builder()        
                .projectId("<PROJECT-ID>")
                .roleName("myCustomRole")
                .actions(            
                    CustomDbRoleActionArgs.builder()
                        .action("UPDATE")
                        .resources(CustomDbRoleActionResourceArgs.builder()
                            .collectionName("")
                            .databaseName("anyDatabase")
                            .build())
                        .build(),
                    CustomDbRoleActionArgs.builder()
                        .action("INSERT")
                        .resources(CustomDbRoleActionResourceArgs.builder()
                            .collectionName("")
                            .databaseName("anyDatabase")
                            .build())
                        .build())
                .build());
    
            final var test = MongodbatlasFunctions.getCustomDbRole(GetCustomDbRoleArgs.builder()
                .projectId(testRole.projectId())
                .roleName(testRole.roleName())
                .build());
    
        }
    }
    
    resources:
      testRole:
        type: mongodbatlas:CustomDbRole
        properties:
          projectId: <PROJECT-ID>
          roleName: myCustomRole
          actions:
            - action: UPDATE
              resources:
                - collectionName:
                  databaseName: anyDatabase
            - action: INSERT
              resources:
                - collectionName:
                  databaseName: anyDatabase
    variables:
      test:
        fn::invoke:
          Function: mongodbatlas:getCustomDbRole
          Arguments:
            projectId: ${testRole.projectId}
            roleName: ${testRole.roleName}
    

    Using getCustomDbRole

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getCustomDbRole(args: GetCustomDbRoleArgs, opts?: InvokeOptions): Promise<GetCustomDbRoleResult>
    function getCustomDbRoleOutput(args: GetCustomDbRoleOutputArgs, opts?: InvokeOptions): Output<GetCustomDbRoleResult>
    def get_custom_db_role(inherited_roles: Optional[Sequence[GetCustomDbRoleInheritedRole]] = None,
                           project_id: Optional[str] = None,
                           role_name: Optional[str] = None,
                           opts: Optional[InvokeOptions] = None) -> GetCustomDbRoleResult
    def get_custom_db_role_output(inherited_roles: Optional[pulumi.Input[Sequence[pulumi.Input[GetCustomDbRoleInheritedRoleArgs]]]] = None,
                           project_id: Optional[pulumi.Input[str]] = None,
                           role_name: Optional[pulumi.Input[str]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetCustomDbRoleResult]
    func LookupCustomDbRole(ctx *Context, args *LookupCustomDbRoleArgs, opts ...InvokeOption) (*LookupCustomDbRoleResult, error)
    func LookupCustomDbRoleOutput(ctx *Context, args *LookupCustomDbRoleOutputArgs, opts ...InvokeOption) LookupCustomDbRoleResultOutput

    > Note: This function is named LookupCustomDbRole in the Go SDK.

    public static class GetCustomDbRole 
    {
        public static Task<GetCustomDbRoleResult> InvokeAsync(GetCustomDbRoleArgs args, InvokeOptions? opts = null)
        public static Output<GetCustomDbRoleResult> Invoke(GetCustomDbRoleInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetCustomDbRoleResult> getCustomDbRole(GetCustomDbRoleArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: mongodbatlas:index/getCustomDbRole:getCustomDbRole
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ProjectId string
    The unique ID for the project to create the database user.
    RoleName string
    Name of the custom role.
    InheritedRoles List<GetCustomDbRoleInheritedRole>
    ProjectId string
    The unique ID for the project to create the database user.
    RoleName string
    Name of the custom role.
    InheritedRoles []GetCustomDbRoleInheritedRole
    projectId String
    The unique ID for the project to create the database user.
    roleName String
    Name of the custom role.
    inheritedRoles List<GetCustomDbRoleInheritedRole>
    projectId string
    The unique ID for the project to create the database user.
    roleName string
    Name of the custom role.
    inheritedRoles GetCustomDbRoleInheritedRole[]
    project_id str
    The unique ID for the project to create the database user.
    role_name str
    Name of the custom role.
    inherited_roles Sequence[GetCustomDbRoleInheritedRole]
    projectId String
    The unique ID for the project to create the database user.
    roleName String
    Name of the custom role.
    inheritedRoles List<Property Map>

    getCustomDbRole Result

    The following output properties are available:

    Actions List<GetCustomDbRoleAction>
    Id string
    The provider-assigned unique ID for this managed resource.
    ProjectId string
    RoleName string
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    InheritedRoles List<GetCustomDbRoleInheritedRole>
    Actions []GetCustomDbRoleAction
    Id string
    The provider-assigned unique ID for this managed resource.
    ProjectId string
    RoleName string
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    InheritedRoles []GetCustomDbRoleInheritedRole
    actions List<GetCustomDbRoleAction>
    id String
    The provider-assigned unique ID for this managed resource.
    projectId String
    roleName String
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    inheritedRoles List<GetCustomDbRoleInheritedRole>
    actions GetCustomDbRoleAction[]
    id string
    The provider-assigned unique ID for this managed resource.
    projectId string
    roleName string
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    inheritedRoles GetCustomDbRoleInheritedRole[]
    actions Sequence[GetCustomDbRoleAction]
    id str
    The provider-assigned unique ID for this managed resource.
    project_id str
    role_name str
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    inherited_roles Sequence[GetCustomDbRoleInheritedRole]
    actions List<Property Map>
    id String
    The provider-assigned unique ID for this managed resource.
    projectId String
    roleName String
    (Required) Name of the inherited role. This can either be another custom role or a built-in role.
    inheritedRoles List<Property Map>

    Supporting Types

    GetCustomDbRoleAction

    Action string
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    Resources List<GetCustomDbRoleActionResource>
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.
    Action string
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    Resources []GetCustomDbRoleActionResource
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.
    action String
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    resources List<GetCustomDbRoleActionResource>
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.
    action string
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    resources GetCustomDbRoleActionResource[]
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.
    action str
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    resources Sequence[GetCustomDbRoleActionResource]
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.
    action String
    (Required) Name of the privilege action. For a complete list of actions available in the Atlas API, see Custom Role Actions.
    resources List<Property Map>
    (Required) Contains information on where the action is granted. Each object in the array either indicates a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.

    GetCustomDbRoleActionResource

    Cluster bool
    CollectionName string
    DatabaseName string
    (Required) Database on which the inherited role is granted.
    Cluster bool
    CollectionName string
    DatabaseName string
    (Required) Database on which the inherited role is granted.
    cluster Boolean
    collectionName String
    databaseName String
    (Required) Database on which the inherited role is granted.
    cluster boolean
    collectionName string
    databaseName string
    (Required) Database on which the inherited role is granted.
    cluster bool
    collection_name str
    database_name str
    (Required) Database on which the inherited role is granted.
    cluster Boolean
    collectionName String
    databaseName String
    (Required) Database on which the inherited role is granted.

    GetCustomDbRoleInheritedRole

    DatabaseName string
    (Required) Database on which the inherited role is granted.
    RoleName string
    Name of the custom role.
    DatabaseName string
    (Required) Database on which the inherited role is granted.
    RoleName string
    Name of the custom role.
    databaseName String
    (Required) Database on which the inherited role is granted.
    roleName String
    Name of the custom role.
    databaseName string
    (Required) Database on which the inherited role is granted.
    roleName string
    Name of the custom role.
    database_name str
    (Required) Database on which the inherited role is granted.
    role_name str
    Name of the custom role.
    databaseName String
    (Required) Database on which the inherited role is granted.
    roleName String
    Name of the custom role.

    Package Details

    Repository
    MongoDB Atlas pulumi/pulumi-mongodbatlas
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mongodbatlas Terraform Provider.
    mongodbatlas logo
    MongoDB Atlas v3.14.2 published on Monday, Mar 18, 2024 by Pulumi