2020-07-02 14:23:56 -07:00
---
2020-10-06 20:34:16 -04:00
page_title : "boundary_role Resource - terraform-provider-boundary"
subcategory : ""
2020-07-02 14:23:56 -07:00
description : |-
2020-10-06 20:34:16 -04:00
The role resource allows you to configure a Boundary role.
2020-07-02 14:23:56 -07:00
---
2020-10-06 20:34:16 -04:00
# Resource `boundary_role`
The role resource allows you to configure a Boundary role.
2020-07-02 14:23:56 -07:00
## Example Usage
2020-10-06 20:34:16 -04:00
2020-07-10 15:32:44 -07:00
Basic usage:
2020-07-02 14:23:56 -07:00
2020-10-06 20:34:16 -04:00
```terraform
2020-09-17 15:34:00 -07:00
resource "boundary_scope" "org" {
2020-10-13 23:12:03 -04:00
name = "organization_one"
description = "My first scope!"
scope_id = "global"
auto_create_admin_role = true
auto_create_default_role = true
2020-09-17 15:34:00 -07:00
}
2020-08-27 16:54:03 -07:00
2020-08-11 16:12:26 -07:00
resource "boundary_role" "example" {
2020-07-02 14:23:56 -07:00
name = "My role"
description = "My first role!"
2020-09-17 15:34:00 -07:00
scope_id = boundary_scope . org . id
2020-07-02 14:23:56 -07:00
}
```
2020-07-10 15:32:44 -07:00
Usage with a user resource:
2020-10-06 20:34:16 -04:00
```terraform
2020-09-17 15:34:00 -07:00
resource "boundary_scope" "org" {
2020-10-13 23:12:03 -04:00
name = "organization_one"
description = "My first scope!"
scope_id = "global"
auto_create_admin_role = true
auto_create_default_role = true
2020-09-17 15:34:00 -07:00
}
2020-08-27 16:54:03 -07:00
2020-08-11 16:12:26 -07:00
resource "boundary_user" "foo" {
2020-08-27 16:54:03 -07:00
name = "User 1"
2020-09-17 15:34:00 -07:00
scope_id = boundary_scope . org . id
2020-07-10 15:32:44 -07:00
}
2020-08-11 16:12:26 -07:00
resource "boundary_user" "bar" {
2020-08-27 16:54:03 -07:00
name = "User 2"
2020-09-17 15:34:00 -07:00
scope_id = boundary_scope . org . id
2020-07-10 15:32:44 -07:00
}
2020-08-11 16:12:26 -07:00
resource "boundary_role" "example" {
2021-09-02 00:36:33 +03:00
name = "My role"
description = "My first role!"
principal_ids = [ boundary_user . foo . id , boundary_user . bar . id ]
scope_id = boundary_scope . org . id
2020-07-12 15:00:16 -07:00
}
```
Usage with user and grants resource:
2020-10-06 20:34:16 -04:00
```terraform
2020-09-17 15:34:00 -07:00
resource "boundary_scope" "org" {
2020-10-13 23:12:03 -04:00
name = "organization_one"
description = "My first scope!"
scope_id = "global"
auto_create_admin_role = true
auto_create_default_role = true
2020-09-17 15:34:00 -07:00
}
2020-08-27 16:54:03 -07:00
2020-08-11 16:12:26 -07:00
resource "boundary_user" "readonly" {
2020-08-27 16:54:03 -07:00
name = "readonly"
2020-07-12 15:00:16 -07:00
description = "A readonly user"
2020-09-17 15:34:00 -07:00
scope_id = boundary_scope . org . id
2020-07-12 15:00:16 -07:00
}
2020-08-11 16:12:26 -07:00
resource "boundary_role" "readonly" {
2021-09-02 00:36:33 +03:00
name = "readonly"
description = "A readonly role"
principal_ids = [ boundary_user . readonly . id ]
2021-09-08 21:02:12 +01:00
grant_strings = [ "id=*;type=*;actions=read" ]
2021-09-02 00:36:33 +03:00
scope_id = boundary_scope . org . id
2020-07-10 15:32:44 -07:00
}
```
2020-08-15 14:49:09 -07:00
Usage for a project-specific role:
2020-10-06 20:34:16 -04:00
```terraform
2020-09-17 15:34:00 -07:00
resource "boundary_scope" "org" {
2020-10-13 23:12:03 -04:00
name = "organization_one"
description = "My first scope!"
scope_id = "global"
auto_create_admin_role = true
auto_create_default_role = true
2020-09-17 15:34:00 -07:00
}
2020-08-27 16:54:03 -07:00
2020-09-17 15:34:00 -07:00
resource "boundary_scope" "project" {
2021-01-14 14:07:36 -08:00
name = "project_one"
description = "My first scope!"
scope_id = boundary_scope . org . id
auto_create_admin_role = true
2020-08-15 14:49:09 -07:00
}
resource "boundary_user" "readonly" {
name = "readonly"
description = "A readonly user"
2020-09-17 15:34:00 -07:00
scope_id = boundary_scope . org . id
2020-08-15 14:49:09 -07:00
}
resource "boundary_role" "readonly" {
2021-09-02 00:36:33 +03:00
name = "readonly"
description = "A readonly role"
principal_ids = [ boundary_user . readonly . id ]
2021-09-08 21:02:12 +01:00
grant_strings = [ "id=*;type=*;actions=read" ]
2021-09-02 00:36:33 +03:00
scope_id = boundary_scope . project . id
2020-08-15 14:49:09 -07:00
}
```
2021-01-14 14:07:36 -08:00
<!-- schema generated by tfplugindocs -->
2020-10-06 20:34:16 -04:00
## Schema
### Required
2021-01-14 14:07:36 -08:00
- **scope_id** (String) The scope ID in which the resource is created. Defaults to the provider's `default_scope` if unset.
2020-10-06 20:34:16 -04:00
### Optional
2020-07-02 14:23:56 -07:00
2021-01-14 14:07:36 -08:00
- **default_role** (Boolean) Indicates that the role containing this value is the default role (that is, has the id 'r_default'), which triggers some specialized behavior to allow it to be imported and managed.
- **description** (String) The role description.
- **grant_scope_id** (String)
- **grant_strings** (Set of String) A list of stringified grants for the role.
- **name** (String) The role name. Defaults to the resource name.
- **principal_ids** (Set of String) A list of principal (user or group) IDs to add as principals on the role.
2020-10-07 12:04:11 -04:00
2021-05-05 10:02:53 -07:00
### Read-Only
2020-10-19 12:40:50 -04:00
2021-01-14 14:07:36 -08:00
- **id** (String) The ID of the role.
2020-10-19 12:40:50 -04:00
2020-10-07 12:04:11 -04:00
## Import
Import is supported using the following syntax:
```shell
terraform import boundary_role.foo <my-id>
2020-10-13 23:12:03 -04:00
```