openstack.identity.RoleAssignment
Explore with Pulumi AI
Manages a V3 Role assignment within OpenStack Keystone.
Note: You must have admin privileges in your OpenStack cloud to use this resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as openstack from "@pulumi/openstack";
const project1 = new openstack.identity.Project("project_1", {name: "project_1"});
const user1 = new openstack.identity.User("user_1", {
name: "user_1",
defaultProjectId: project1.id,
});
const role1 = new openstack.identity.Role("role_1", {name: "role_1"});
const roleAssignment1 = new openstack.identity.RoleAssignment("role_assignment_1", {
userId: user1.id,
projectId: project1.id,
roleId: role1.id,
});
import pulumi
import pulumi_openstack as openstack
project1 = openstack.identity.Project("project_1", name="project_1")
user1 = openstack.identity.User("user_1",
name="user_1",
default_project_id=project1.id)
role1 = openstack.identity.Role("role_1", name="role_1")
role_assignment1 = openstack.identity.RoleAssignment("role_assignment_1",
user_id=user1.id,
project_id=project1.id,
role_id=role1.id)
package main
import (
"github.com/pulumi/pulumi-openstack/sdk/v5/go/openstack/identity"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
project1, err := identity.NewProject(ctx, "project_1", &identity.ProjectArgs{
Name: pulumi.String("project_1"),
})
if err != nil {
return err
}
user1, err := identity.NewUser(ctx, "user_1", &identity.UserArgs{
Name: pulumi.String("user_1"),
DefaultProjectId: project1.ID(),
})
if err != nil {
return err
}
role1, err := identity.NewRole(ctx, "role_1", &identity.RoleArgs{
Name: pulumi.String("role_1"),
})
if err != nil {
return err
}
_, err = identity.NewRoleAssignment(ctx, "role_assignment_1", &identity.RoleAssignmentArgs{
UserId: user1.ID(),
ProjectId: project1.ID(),
RoleId: role1.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var project1 = new OpenStack.Identity.Project("project_1", new()
{
Name = "project_1",
});
var user1 = new OpenStack.Identity.User("user_1", new()
{
Name = "user_1",
DefaultProjectId = project1.Id,
});
var role1 = new OpenStack.Identity.Role("role_1", new()
{
Name = "role_1",
});
var roleAssignment1 = new OpenStack.Identity.RoleAssignment("role_assignment_1", new()
{
UserId = user1.Id,
ProjectId = project1.Id,
RoleId = role1.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openstack.identity.Project;
import com.pulumi.openstack.identity.ProjectArgs;
import com.pulumi.openstack.identity.User;
import com.pulumi.openstack.identity.UserArgs;
import com.pulumi.openstack.identity.Role;
import com.pulumi.openstack.identity.RoleArgs;
import com.pulumi.openstack.identity.RoleAssignment;
import com.pulumi.openstack.identity.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) {
var project1 = new Project("project1", ProjectArgs.builder()
.name("project_1")
.build());
var user1 = new User("user1", UserArgs.builder()
.name("user_1")
.defaultProjectId(project1.id())
.build());
var role1 = new Role("role1", RoleArgs.builder()
.name("role_1")
.build());
var roleAssignment1 = new RoleAssignment("roleAssignment1", RoleAssignmentArgs.builder()
.userId(user1.id())
.projectId(project1.id())
.roleId(role1.id())
.build());
}
}
resources:
project1:
type: openstack:identity:Project
name: project_1
properties:
name: project_1
user1:
type: openstack:identity:User
name: user_1
properties:
name: user_1
defaultProjectId: ${project1.id}
role1:
type: openstack:identity:Role
name: role_1
properties:
name: role_1
roleAssignment1:
type: openstack:identity:RoleAssignment
name: role_assignment_1
properties:
userId: ${user1.id}
projectId: ${project1.id}
roleId: ${role1.id}
Create RoleAssignment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RoleAssignment(name: string, args: RoleAssignmentArgs, opts?: CustomResourceOptions);
@overload
def RoleAssignment(resource_name: str,
args: RoleAssignmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RoleAssignment(resource_name: str,
opts: Optional[ResourceOptions] = None,
role_id: Optional[str] = None,
domain_id: Optional[str] = None,
group_id: Optional[str] = None,
project_id: Optional[str] = None,
region: Optional[str] = None,
user_id: Optional[str] = None)
func NewRoleAssignment(ctx *Context, name string, args RoleAssignmentArgs, opts ...ResourceOption) (*RoleAssignment, error)
public RoleAssignment(string name, RoleAssignmentArgs args, CustomResourceOptions? opts = null)
public RoleAssignment(String name, RoleAssignmentArgs args)
public RoleAssignment(String name, RoleAssignmentArgs args, CustomResourceOptions options)
type: openstack:identity:RoleAssignment
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 RoleAssignmentArgs
- 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 RoleAssignmentArgs
- 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 RoleAssignmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RoleAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RoleAssignmentArgs
- 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 roleAssignmentResource = new OpenStack.Identity.RoleAssignment("roleAssignmentResource", new()
{
RoleId = "string",
DomainId = "string",
GroupId = "string",
ProjectId = "string",
Region = "string",
UserId = "string",
});
example, err := identity.NewRoleAssignment(ctx, "roleAssignmentResource", &identity.RoleAssignmentArgs{
RoleId: pulumi.String("string"),
DomainId: pulumi.String("string"),
GroupId: pulumi.String("string"),
ProjectId: pulumi.String("string"),
Region: pulumi.String("string"),
UserId: pulumi.String("string"),
})
var roleAssignmentResource = new RoleAssignment("roleAssignmentResource", RoleAssignmentArgs.builder()
.roleId("string")
.domainId("string")
.groupId("string")
.projectId("string")
.region("string")
.userId("string")
.build());
role_assignment_resource = openstack.identity.RoleAssignment("roleAssignmentResource",
role_id="string",
domain_id="string",
group_id="string",
project_id="string",
region="string",
user_id="string")
const roleAssignmentResource = new openstack.identity.RoleAssignment("roleAssignmentResource", {
roleId: "string",
domainId: "string",
groupId: "string",
projectId: "string",
region: "string",
userId: "string",
});
type: openstack:identity:RoleAssignment
properties:
domainId: string
groupId: string
projectId: string
region: string
roleId: string
userId: string
RoleAssignment 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 RoleAssignment resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the RoleAssignment 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 RoleAssignment Resource
Get an existing RoleAssignment 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?: RoleAssignmentState, opts?: CustomResourceOptions): RoleAssignment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
domain_id: Optional[str] = None,
group_id: Optional[str] = None,
project_id: Optional[str] = None,
region: Optional[str] = None,
role_id: Optional[str] = None,
user_id: Optional[str] = None) -> RoleAssignment
func GetRoleAssignment(ctx *Context, name string, id IDInput, state *RoleAssignmentState, opts ...ResourceOption) (*RoleAssignment, error)
public static RoleAssignment Get(string name, Input<string> id, RoleAssignmentState? state, CustomResourceOptions? opts = null)
public static RoleAssignment get(String name, Output<String> id, RoleAssignmentState 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.
Import
Role assignments can be imported using a constructed id. The id should have the form of
domainID/projectID/groupID/userID/roleID
. When something is not used then leave blank.
For example this will import the role assignment for: projectID: 014395cd-89fc-4c9b-96b7-13d1ee79dad2, userID: 4142e64b-1b35-44a0-9b1e-5affc7af1106, roleID: ea257959-eeb1-4c10-8d33-26f0409a755d ( domainID and groupID are left blank)
$ pulumi import openstack:identity/roleAssignment:RoleAssignment role_assignment_1 /014395cd-89fc-4c9b-96b7-13d1ee79dad2//4142e64b-1b35-44a0-9b1e-5affc7af1106/ea257959-eeb1-4c10-8d33-26f0409a755d
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- OpenStack pulumi/pulumi-openstack
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
openstack
Terraform Provider.