Allows management of a customized Cloud IAM project role. For more information see the official documentation and API.
This snippet creates a customized IAM role.
resource "google_project_iam_custom_role" "my-custom-role" {
role_id = "myCustomRole"
title = "My Custom Role"
description = "A description"
permissions = ["iam.roles.list", "iam.roles.create", "iam.roles.delete"]
}
The following arguments are supported:
role_id
- (Required) The camel case role id to use for this role. Cannot contain -
characters.
title
- (Required) A human-readable title for the role.
permissions
(Required) The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
project
- (Optional) The project that the custom role will be created in.
Defaults to the provider project configuration.
stage
- (Optional) The current launch stage of the role.
Defaults to GA
.
List of possible stages is here.
description
- (Optional) A human-readable description for the role.
In addition to the arguments listed above, the following computed attributes are exported:
deleted
- (Optional) The current deleted state of the role.
id
- an identifier for the resource with the format projects/{{project}}/roles/{{role_id}}
name
- The name of the role in the format projects/{{project}}/roles/{{role_id}}
. Like id
, this field can be used as a reference in other resources such as IAM role bindings.
Custom Roles can be imported using any of these accepted formats:
projects/{{project}}/roles/{{role_id}}
{{project}}/{{role_id}}
{{role_id}}
In Terraform v1.5.0 and later, use an import
block to import Custom Roles using one of the formats above. For example:
import {
id = "projects/{{project}}/roles/{{role_id}}"
to = google_project_iam_custom_role.default
}
When using the terraform import
command, Custom Roles can be imported using one of the formats above. For example:
$ terraform import google_project_iam_custom_role.default projects/{{project}}/roles/{{role_id}}
$ terraform import google_project_iam_custom_role.default {{project}}/{{role_id}}
$ terraform import google_project_iam_custom_role.default {{role_id}}