Google Cloud v8.21.0 published on Wednesday, Mar 5, 2025 by Pulumi
gcp.iam.getRule
Explore with Pulumi AI
Use this data source to get information about a Google IAM Role.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const roleinfo = gcp.iam.getRule({
    name: "roles/compute.viewer",
});
export const theRolePermissions = roleinfo.then(roleinfo => roleinfo.includedPermissions);
import pulumi
import pulumi_gcp as gcp
roleinfo = gcp.iam.get_rule(name="roles/compute.viewer")
pulumi.export("theRolePermissions", roleinfo.included_permissions)
package main
import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		roleinfo, err := iam.GetRule(ctx, &iam.GetRuleArgs{
			Name: "roles/compute.viewer",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("theRolePermissions", roleinfo.IncludedPermissions)
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() => 
{
    var roleinfo = Gcp.Iam.GetRule.Invoke(new()
    {
        Name = "roles/compute.viewer",
    });
    return new Dictionary<string, object?>
    {
        ["theRolePermissions"] = roleinfo.Apply(getRuleResult => getRuleResult.IncludedPermissions),
    };
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.iam.IamFunctions;
import com.pulumi.gcp.iam.inputs.GetRuleArgs;
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 roleinfo = IamFunctions.getRule(GetRuleArgs.builder()
            .name("roles/compute.viewer")
            .build());
        ctx.export("theRolePermissions", roleinfo.applyValue(getRuleResult -> getRuleResult.includedPermissions()));
    }
}
variables:
  roleinfo:
    fn::invoke:
      function: gcp:iam:getRule
      arguments:
        name: roles/compute.viewer
outputs:
  theRolePermissions: ${roleinfo.includedPermissions}
Using getRule
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getRule(args: GetRuleArgs, opts?: InvokeOptions): Promise<GetRuleResult>
function getRuleOutput(args: GetRuleOutputArgs, opts?: InvokeOptions): Output<GetRuleResult>def get_rule(name: Optional[str] = None,
             opts: Optional[InvokeOptions] = None) -> GetRuleResult
def get_rule_output(name: Optional[pulumi.Input[str]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetRuleResult]func GetRule(ctx *Context, args *GetRuleArgs, opts ...InvokeOption) (*GetRuleResult, error)
func GetRuleOutput(ctx *Context, args *GetRuleOutputArgs, opts ...InvokeOption) GetRuleResultOutput> Note: This function is named GetRule in the Go SDK.
public static class GetRule 
{
    public static Task<GetRuleResult> InvokeAsync(GetRuleArgs args, InvokeOptions? opts = null)
    public static Output<GetRuleResult> Invoke(GetRuleInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetRuleResult> getRule(GetRuleArgs args, InvokeOptions options)
public static Output<GetRuleResult> getRule(GetRuleArgs args, InvokeOptions options)
fn::invoke:
  function: gcp:iam/getRule:getRule
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Name string
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
- Name string
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
- name String
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
- name string
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
- name str
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
- name String
- The name of the Role to lookup in the form roles/{ROLE_NAME},organizations/{ORGANIZATION_ID}/roles/{ROLE_NAME}orprojects/{PROJECT_ID}/roles/{ROLE_NAME}
getRule Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- IncludedPermissions List<string>
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- Name string
- Stage string
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- Title string
- is a friendly title for the role, such as "Role Viewer"
- Id string
- The provider-assigned unique ID for this managed resource.
- IncludedPermissions []string
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- Name string
- Stage string
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- Title string
- is a friendly title for the role, such as "Role Viewer"
- id String
- The provider-assigned unique ID for this managed resource.
- includedPermissions List<String>
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- name String
- stage String
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- title String
- is a friendly title for the role, such as "Role Viewer"
- id string
- The provider-assigned unique ID for this managed resource.
- includedPermissions string[]
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- name string
- stage string
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- title string
- is a friendly title for the role, such as "Role Viewer"
- id str
- The provider-assigned unique ID for this managed resource.
- included_permissions Sequence[str]
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- name str
- stage str
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- title str
- is a friendly title for the role, such as "Role Viewer"
- id String
- The provider-assigned unique ID for this managed resource.
- includedPermissions List<String>
- specifies the list of one or more permissions to include in the custom role, such as - iam.roles.get
- name String
- stage String
- indicates the stage of a role in the launch lifecycle, such as GA,BETAorALPHA.
- title String
- is a friendly title for the role, such as "Role Viewer"
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the google-betaTerraform Provider.