Role Assignment Args
Assigns a given Principal (User or Group) to a given Role in a Private Azure Marketplace.
Example Usage
Using A Role Definition Name)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.core.getClientConfig({});
const exampleRoleAssignment = new azure.marketplace.RoleAssignment("example", {
roleDefinitionName: "Marketplace Admin",
principalId: example.then(example => example.objectId),
});
import pulumi
import pulumi_azure as azure
example = azure.core.get_client_config()
example_role_assignment = azure.marketplace.RoleAssignment("example",
role_definition_name="Marketplace Admin",
principal_id=example.object_id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Core.GetClientConfig.Invoke();
var exampleRoleAssignment = new Azure.Marketplace.RoleAssignment("example", new()
{
RoleDefinitionName = "Marketplace Admin",
PrincipalId = example.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/marketplace"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.GetClientConfig(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
_, err = marketplace.NewRoleAssignment(ctx, "example", &marketplace.RoleAssignmentArgs{
RoleDefinitionName: pulumi.String("Marketplace Admin"),
PrincipalId: pulumi.String(example.ObjectId),
})
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.azure.core.CoreFunctions;
import com.pulumi.azure.marketplace.RoleAssignment;
import com.pulumi.azure.marketplace.RoleAssignmentArgs;
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) {
final var example = CoreFunctions.getClientConfig(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
var exampleRoleAssignment = new RoleAssignment("exampleRoleAssignment", RoleAssignmentArgs.builder()
.roleDefinitionName("Marketplace Admin")
.principalId(example.objectId())
.build());
}
}
resources:
exampleRoleAssignment:
type: azure:marketplace:RoleAssignment
name: example
properties:
roleDefinitionName: Marketplace Admin
principalId: ${example.objectId}
variables:
example:
fn::invoke:
function: azure:core:getClientConfig
arguments: {}
Using A Role Definition ID)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.core.getClientConfig({});
const exampleGetRoleDefinition = azure.authorization.getRoleDefinition({
name: "Log Analytics Reader",
});
const exampleRoleAssignment = new azure.marketplace.RoleAssignment("example", {
roleDefinitionId: exampleGetRoleDefinition.then(exampleGetRoleDefinition => exampleGetRoleDefinition.id),
principalId: example.then(example => example.objectId),
});
import pulumi
import pulumi_azure as azure
example = azure.core.get_client_config()
example_get_role_definition = azure.authorization.get_role_definition(name="Log Analytics Reader")
example_role_assignment = azure.marketplace.RoleAssignment("example",
role_definition_id=example_get_role_definition.id,
principal_id=example.object_id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Core.GetClientConfig.Invoke();
var exampleGetRoleDefinition = Azure.Authorization.GetRoleDefinition.Invoke(new()
{
Name = "Log Analytics Reader",
});
var exampleRoleAssignment = new Azure.Marketplace.RoleAssignment("example", new()
{
RoleDefinitionId = exampleGetRoleDefinition.Apply(getRoleDefinitionResult => getRoleDefinitionResult.Id),
PrincipalId = example.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/authorization"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/marketplace"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.GetClientConfig(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
exampleGetRoleDefinition, err := authorization.LookupRoleDefinition(ctx, &authorization.LookupRoleDefinitionArgs{
Name: pulumi.StringRef("Log Analytics Reader"),
}, nil)
if err != nil {
return err
}
_, err = marketplace.NewRoleAssignment(ctx, "example", &marketplace.RoleAssignmentArgs{
RoleDefinitionId: pulumi.String(exampleGetRoleDefinition.Id),
PrincipalId: pulumi.String(example.ObjectId),
})
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.azure.core.CoreFunctions;
import com.pulumi.azure.authorization.AuthorizationFunctions;
import com.pulumi.azure.authorization.inputs.GetRoleDefinitionArgs;
import com.pulumi.azure.marketplace.RoleAssignment;
import com.pulumi.azure.marketplace.RoleAssignmentArgs;
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) {
final var example = CoreFunctions.getClientConfig(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
final var exampleGetRoleDefinition = AuthorizationFunctions.getRoleDefinition(GetRoleDefinitionArgs.builder()
.name("Log Analytics Reader")
.build());
var exampleRoleAssignment = new RoleAssignment("exampleRoleAssignment", RoleAssignmentArgs.builder()
.roleDefinitionId(exampleGetRoleDefinition.id())
.principalId(example.objectId())
.build());
}
}
resources:
exampleRoleAssignment:
type: azure:marketplace:RoleAssignment
name: example
properties:
roleDefinitionId: ${exampleGetRoleDefinition.id}
principalId: ${example.objectId}
variables:
example:
fn::invoke:
function: azure:core:getClientConfig
arguments: {}
exampleGetRoleDefinition:
fn::invoke:
function: azure:authorization:getRoleDefinition
arguments:
name: Log Analytics Reader
API Providers
This resource uses the following Azure API Providers:
Microsoft.Authorization
: 2022-05-01-preview, 2022-04-01
Import
Role Assignments can be imported using the resource id
, e.g.
$ pulumi import azure:marketplace/roleAssignment:RoleAssignment example /providers/Microsoft.Marketplace/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000
text /providers/Microsoft.Marketplace/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000|00000000-0000-0000-0000-000000000000
Constructors
Properties
The version of the condition. Possible values are 1.0
or 2.0
. Changing this forces a new resource to be created.
The delegated Azure Resource ID which contains a Managed Identity. Changing this forces a new resource to be created.
The description for this Role Assignment. Changing this forces a new resource to be created.
The ID of the Principal (User, Group or Service Principal) to assign the Role Definition to. Changing this forces a new resource to be created.
The Scoped-ID of the Role Definition. Changing this forces a new resource to be created. Conflicts with role_definition_name
.
The name of a built-in Role. Changing this forces a new resource to be created. Conflicts with role_definition_id
.
If the principal_id
is a newly provisioned Service Principal
set this value to true
to skip the Azure Active Directory
check which may fail due to replication lag. This argument is only valid if the principal_id
is a Service Principal
identity. Defaults to false
. Changing this forces a new resource to be created.