1. Packages
  2. Opensearch Provider
  3. API Docs
  4. RolesMapping
opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project

opensearch.RolesMapping

Explore with Pulumi AI

Provides an OpenSearch security role mapping. Please refer to the OpenSearch Access Control documentation for details.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as opensearch from "@pulumi/opensearch";

// Create a role mapping
const mapper = new opensearch.RolesMapping("mapper", {
    backendRoles: [
        "arn:aws:iam::123456789012:role/lambda-call-opensearch",
        "arn:aws:iam::123456789012:role/run-containers",
    ],
    description: "Mapping AWS IAM roles to ES role",
    roleName: "logs_writer",
});
Copy
import pulumi
import pulumi_opensearch as opensearch

# Create a role mapping
mapper = opensearch.RolesMapping("mapper",
    backend_roles=[
        "arn:aws:iam::123456789012:role/lambda-call-opensearch",
        "arn:aws:iam::123456789012:role/run-containers",
    ],
    description="Mapping AWS IAM roles to ES role",
    role_name="logs_writer")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/opensearch/v2/opensearch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a role mapping
		_, err := opensearch.NewRolesMapping(ctx, "mapper", &opensearch.RolesMappingArgs{
			BackendRoles: pulumi.StringArray{
				pulumi.String("arn:aws:iam::123456789012:role/lambda-call-opensearch"),
				pulumi.String("arn:aws:iam::123456789012:role/run-containers"),
			},
			Description: pulumi.String("Mapping AWS IAM roles to ES role"),
			RoleName:    pulumi.String("logs_writer"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opensearch = Pulumi.Opensearch;

return await Deployment.RunAsync(() => 
{
    // Create a role mapping
    var mapper = new Opensearch.RolesMapping("mapper", new()
    {
        BackendRoles = new[]
        {
            "arn:aws:iam::123456789012:role/lambda-call-opensearch",
            "arn:aws:iam::123456789012:role/run-containers",
        },
        Description = "Mapping AWS IAM roles to ES role",
        RoleName = "logs_writer",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opensearch.RolesMapping;
import com.pulumi.opensearch.RolesMappingArgs;
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) {
        // Create a role mapping
        var mapper = new RolesMapping("mapper", RolesMappingArgs.builder()
            .backendRoles(            
                "arn:aws:iam::123456789012:role/lambda-call-opensearch",
                "arn:aws:iam::123456789012:role/run-containers")
            .description("Mapping AWS IAM roles to ES role")
            .roleName("logs_writer")
            .build());

    }
}
Copy
resources:
  # Create a role mapping
  mapper:
    type: opensearch:RolesMapping
    properties:
      backendRoles:
        - arn:aws:iam::123456789012:role/lambda-call-opensearch
        - arn:aws:iam::123456789012:role/run-containers
      description: Mapping AWS IAM roles to ES role
      roleName: logs_writer
Copy

Create RolesMapping Resource

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

Constructor syntax

new RolesMapping(name: string, args: RolesMappingArgs, opts?: CustomResourceOptions);
@overload
def RolesMapping(resource_name: str,
                 args: RolesMappingArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def RolesMapping(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 role_name: Optional[str] = None,
                 and_backend_roles: Optional[Sequence[str]] = None,
                 backend_roles: Optional[Sequence[str]] = None,
                 description: Optional[str] = None,
                 hosts: Optional[Sequence[str]] = None,
                 roles_mapping_id: Optional[str] = None,
                 users: Optional[Sequence[str]] = None)
func NewRolesMapping(ctx *Context, name string, args RolesMappingArgs, opts ...ResourceOption) (*RolesMapping, error)
public RolesMapping(string name, RolesMappingArgs args, CustomResourceOptions? opts = null)
public RolesMapping(String name, RolesMappingArgs args)
public RolesMapping(String name, RolesMappingArgs args, CustomResourceOptions options)
type: opensearch:RolesMapping
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RolesMappingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RolesMappingArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RolesMappingArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RolesMappingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RolesMappingArgs
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 rolesMappingResource = new Opensearch.RolesMapping("rolesMappingResource", new()
{
    RoleName = "string",
    AndBackendRoles = new[]
    {
        "string",
    },
    BackendRoles = new[]
    {
        "string",
    },
    Description = "string",
    Hosts = new[]
    {
        "string",
    },
    RolesMappingId = "string",
    Users = new[]
    {
        "string",
    },
});
Copy
example, err := opensearch.NewRolesMapping(ctx, "rolesMappingResource", &opensearch.RolesMappingArgs{
RoleName: pulumi.String("string"),
AndBackendRoles: pulumi.StringArray{
pulumi.String("string"),
},
BackendRoles: pulumi.StringArray{
pulumi.String("string"),
},
Description: pulumi.String("string"),
Hosts: pulumi.StringArray{
pulumi.String("string"),
},
RolesMappingId: pulumi.String("string"),
Users: pulumi.StringArray{
pulumi.String("string"),
},
})
Copy
var rolesMappingResource = new RolesMapping("rolesMappingResource", RolesMappingArgs.builder()
    .roleName("string")
    .andBackendRoles("string")
    .backendRoles("string")
    .description("string")
    .hosts("string")
    .rolesMappingId("string")
    .users("string")
    .build());
Copy
roles_mapping_resource = opensearch.RolesMapping("rolesMappingResource",
    role_name="string",
    and_backend_roles=["string"],
    backend_roles=["string"],
    description="string",
    hosts=["string"],
    roles_mapping_id="string",
    users=["string"])
Copy
const rolesMappingResource = new opensearch.RolesMapping("rolesMappingResource", {
    roleName: "string",
    andBackendRoles: ["string"],
    backendRoles: ["string"],
    description: "string",
    hosts: ["string"],
    rolesMappingId: "string",
    users: ["string"],
});
Copy
type: opensearch:RolesMapping
properties:
    andBackendRoles:
        - string
    backendRoles:
        - string
    description: string
    hosts:
        - string
    roleName: string
    rolesMappingId: string
    users:
        - string
Copy

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

RoleName This property is required. string
The name of the security role.
AndBackendRoles List<string>
A list of backend roles.
BackendRoles List<string>
A list of backend roles.
Description string
Description of the role mapping.
Hosts List<string>
A list of host names.
RolesMappingId string
The ID of this resource.
Users List<string>
A list of users.
RoleName This property is required. string
The name of the security role.
AndBackendRoles []string
A list of backend roles.
BackendRoles []string
A list of backend roles.
Description string
Description of the role mapping.
Hosts []string
A list of host names.
RolesMappingId string
The ID of this resource.
Users []string
A list of users.
roleName This property is required. String
The name of the security role.
andBackendRoles List<String>
A list of backend roles.
backendRoles List<String>
A list of backend roles.
description String
Description of the role mapping.
hosts List<String>
A list of host names.
rolesMappingId String
The ID of this resource.
users List<String>
A list of users.
roleName This property is required. string
The name of the security role.
andBackendRoles string[]
A list of backend roles.
backendRoles string[]
A list of backend roles.
description string
Description of the role mapping.
hosts string[]
A list of host names.
rolesMappingId string
The ID of this resource.
users string[]
A list of users.
role_name This property is required. str
The name of the security role.
and_backend_roles Sequence[str]
A list of backend roles.
backend_roles Sequence[str]
A list of backend roles.
description str
Description of the role mapping.
hosts Sequence[str]
A list of host names.
roles_mapping_id str
The ID of this resource.
users Sequence[str]
A list of users.
roleName This property is required. String
The name of the security role.
andBackendRoles List<String>
A list of backend roles.
backendRoles List<String>
A list of backend roles.
description String
Description of the role mapping.
hosts List<String>
A list of host names.
rolesMappingId String
The ID of this resource.
users List<String>
A list of users.

Outputs

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

Get an existing RolesMapping 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?: RolesMappingState, opts?: CustomResourceOptions): RolesMapping
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        and_backend_roles: Optional[Sequence[str]] = None,
        backend_roles: Optional[Sequence[str]] = None,
        description: Optional[str] = None,
        hosts: Optional[Sequence[str]] = None,
        role_name: Optional[str] = None,
        roles_mapping_id: Optional[str] = None,
        users: Optional[Sequence[str]] = None) -> RolesMapping
func GetRolesMapping(ctx *Context, name string, id IDInput, state *RolesMappingState, opts ...ResourceOption) (*RolesMapping, error)
public static RolesMapping Get(string name, Input<string> id, RolesMappingState? state, CustomResourceOptions? opts = null)
public static RolesMapping get(String name, Output<String> id, RolesMappingState state, CustomResourceOptions options)
resources:  _:    type: opensearch:RolesMapping    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
AndBackendRoles List<string>
A list of backend roles.
BackendRoles List<string>
A list of backend roles.
Description string
Description of the role mapping.
Hosts List<string>
A list of host names.
RoleName string
The name of the security role.
RolesMappingId string
The ID of this resource.
Users List<string>
A list of users.
AndBackendRoles []string
A list of backend roles.
BackendRoles []string
A list of backend roles.
Description string
Description of the role mapping.
Hosts []string
A list of host names.
RoleName string
The name of the security role.
RolesMappingId string
The ID of this resource.
Users []string
A list of users.
andBackendRoles List<String>
A list of backend roles.
backendRoles List<String>
A list of backend roles.
description String
Description of the role mapping.
hosts List<String>
A list of host names.
roleName String
The name of the security role.
rolesMappingId String
The ID of this resource.
users List<String>
A list of users.
andBackendRoles string[]
A list of backend roles.
backendRoles string[]
A list of backend roles.
description string
Description of the role mapping.
hosts string[]
A list of host names.
roleName string
The name of the security role.
rolesMappingId string
The ID of this resource.
users string[]
A list of users.
and_backend_roles Sequence[str]
A list of backend roles.
backend_roles Sequence[str]
A list of backend roles.
description str
Description of the role mapping.
hosts Sequence[str]
A list of host names.
role_name str
The name of the security role.
roles_mapping_id str
The ID of this resource.
users Sequence[str]
A list of users.
andBackendRoles List<String>
A list of backend roles.
backendRoles List<String>
A list of backend roles.
description String
Description of the role mapping.
hosts List<String>
A list of host names.
roleName String
The name of the security role.
rolesMappingId String
The ID of this resource.
users List<String>
A list of users.

Import

$ pulumi import opensearch:index/rolesMapping:RolesMapping mapper logs_writer
Copy

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

Package Details

Repository
opensearch opensearch-project/terraform-provider-opensearch
License
Notes
This Pulumi package is based on the opensearch Terraform Provider.