MongoDB Atlas

v3.5.1 published on Thursday, Sep 15, 2022 by Pulumi

getCustomDbRole

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

using System.Collections.Generic;
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 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: CustomDbRoleActionArray{
				&CustomDbRoleActionArgs{
					Action: pulumi.String("UPDATE"),
					Resources: CustomDbRoleActionResourceArray{
						&CustomDbRoleActionResourceArgs{
							CollectionName: pulumi.String(""),
							DatabaseName:   pulumi.String("anyDatabase"),
						},
					},
				},
				&CustomDbRoleActionArgs{
					Action: pulumi.String("INSERT"),
					Resources: CustomDbRoleActionResourceArray{
						&CustomDbRoleActionResourceArgs{
							CollectionName: pulumi.String(""),
							DatabaseName:   pulumi.String("anyDatabase"),
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		_ = mongodbatlas.LookupCustomDbRoleOutput(ctx, GetCustomDbRoleOutputArgs{
			ProjectId: testRole.ProjectId,
			RoleName:  testRole.RoleName,
		}, nil)
		return nil
	})
}
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());

    }
}
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)
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,
});
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
InheritedRoles List<GetCustomDbRoleInheritedRole>
Actions []GetCustomDbRoleAction
Id string

The provider-assigned unique ID for this managed resource.

ProjectId string
RoleName string
InheritedRoles []GetCustomDbRoleInheritedRole
actions List<GetCustomDbRoleAction>
id String

The provider-assigned unique ID for this managed resource.

projectId String
roleName String
inheritedRoles List<GetCustomDbRoleInheritedRole>
actions GetCustomDbRoleAction[]
id string

The provider-assigned unique ID for this managed resource.

projectId string
roleName string
inheritedRoles GetCustomDbRoleInheritedRole[]
actions List<Property Map>
id String

The provider-assigned unique ID for this managed resource.

projectId String
roleName String
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 Boolean
collectionName String
databaseName String
cluster boolean
collectionName string
databaseName string
cluster Boolean
collectionName String
databaseName String

GetCustomDbRoleInheritedRole

DatabaseName string
RoleName string

Name of the custom role.

DatabaseName string
RoleName string

Name of the custom role.

databaseName String
roleName String

Name of the custom role.

databaseName string
roleName string

Name of the custom role.

database_name str
role_name str

Name of the custom role.

databaseName String
roleName String

Name of the custom role.

Package Details

Repository
https://github.com/pulumi/pulumi-mongodbatlas
License
Apache-2.0
Notes

This Pulumi package is based on the mongodbatlas Terraform Provider.