1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. projects
  5. IAMCustomRole
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

gcp.projects.IAMCustomRole

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Allows management of a customized Cloud IAM project role. For more information see the official documentation and API.

    Warning: Note that custom roles in GCP have the concept of a soft-delete. There are two issues that may arise from this and how roles are propagated. 1) creating a role may involve undeleting and then updating a role with the same name, possibly causing confusing behavior between undelete and update. 2) A deleted role is permanently deleted after 7 days, but it can take up to 30 more days (i.e. between 7 and 37 days after deletion) before the role name is made available again. This means a deleted role that has been deleted for more than 7 days cannot be changed at all by the provider, and new roles cannot share that name.

    Example Usage

    This snippet creates a customized IAM role.

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const my_custom_role = new gcp.projects.IAMCustomRole("my-custom-role", {
        roleId: "myCustomRole",
        title: "My Custom Role",
        description: "A description",
        permissions: [
            "iam.roles.list",
            "iam.roles.create",
            "iam.roles.delete",
        ],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_custom_role = gcp.projects.IAMCustomRole("my-custom-role",
        role_id="myCustomRole",
        title="My Custom Role",
        description="A description",
        permissions=[
            "iam.roles.list",
            "iam.roles.create",
            "iam.roles.delete",
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := projects.NewIAMCustomRole(ctx, "my-custom-role", &projects.IAMCustomRoleArgs{
    			RoleId:      pulumi.String("myCustomRole"),
    			Title:       pulumi.String("My Custom Role"),
    			Description: pulumi.String("A description"),
    			Permissions: pulumi.StringArray{
    				pulumi.String("iam.roles.list"),
    				pulumi.String("iam.roles.create"),
    				pulumi.String("iam.roles.delete"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var my_custom_role = new Gcp.Projects.IAMCustomRole("my-custom-role", new()
        {
            RoleId = "myCustomRole",
            Title = "My Custom Role",
            Description = "A description",
            Permissions = new[]
            {
                "iam.roles.list",
                "iam.roles.create",
                "iam.roles.delete",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.projects.IAMCustomRole;
    import com.pulumi.gcp.projects.IAMCustomRoleArgs;
    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 my_custom_role = new IAMCustomRole("my-custom-role", IAMCustomRoleArgs.builder()
                .roleId("myCustomRole")
                .title("My Custom Role")
                .description("A description")
                .permissions(            
                    "iam.roles.list",
                    "iam.roles.create",
                    "iam.roles.delete")
                .build());
    
        }
    }
    
    resources:
      my-custom-role:
        type: gcp:projects:IAMCustomRole
        properties:
          roleId: myCustomRole
          title: My Custom Role
          description: A description
          permissions:
            - iam.roles.list
            - iam.roles.create
            - iam.roles.delete
    

    Create IAMCustomRole Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new IAMCustomRole(name: string, args: IAMCustomRoleArgs, opts?: CustomResourceOptions);
    @overload
    def IAMCustomRole(resource_name: str,
                      args: IAMCustomRoleArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def IAMCustomRole(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      permissions: Optional[Sequence[str]] = None,
                      role_id: Optional[str] = None,
                      title: Optional[str] = None,
                      description: Optional[str] = None,
                      project: Optional[str] = None,
                      stage: Optional[str] = None)
    func NewIAMCustomRole(ctx *Context, name string, args IAMCustomRoleArgs, opts ...ResourceOption) (*IAMCustomRole, error)
    public IAMCustomRole(string name, IAMCustomRoleArgs args, CustomResourceOptions? opts = null)
    public IAMCustomRole(String name, IAMCustomRoleArgs args)
    public IAMCustomRole(String name, IAMCustomRoleArgs args, CustomResourceOptions options)
    
    type: gcp:projects:IAMCustomRole
    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 IAMCustomRoleArgs
    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 IAMCustomRoleArgs
    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 IAMCustomRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args IAMCustomRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args IAMCustomRoleArgs
    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 gcpIAMCustomRoleResource = new Gcp.Projects.IAMCustomRole("gcpIAMCustomRoleResource", new()
    {
        Permissions = new[]
        {
            "string",
        },
        RoleId = "string",
        Title = "string",
        Description = "string",
        Project = "string",
        Stage = "string",
    });
    
    example, err := projects.NewIAMCustomRole(ctx, "gcpIAMCustomRoleResource", &projects.IAMCustomRoleArgs{
    	Permissions: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	RoleId:      pulumi.String("string"),
    	Title:       pulumi.String("string"),
    	Description: pulumi.String("string"),
    	Project:     pulumi.String("string"),
    	Stage:       pulumi.String("string"),
    })
    
    var gcpIAMCustomRoleResource = new IAMCustomRole("gcpIAMCustomRoleResource", IAMCustomRoleArgs.builder()
        .permissions("string")
        .roleId("string")
        .title("string")
        .description("string")
        .project("string")
        .stage("string")
        .build());
    
    gcp_iam_custom_role_resource = gcp.projects.IAMCustomRole("gcpIAMCustomRoleResource",
        permissions=["string"],
        role_id="string",
        title="string",
        description="string",
        project="string",
        stage="string")
    
    const gcpIAMCustomRoleResource = new gcp.projects.IAMCustomRole("gcpIAMCustomRoleResource", {
        permissions: ["string"],
        roleId: "string",
        title: "string",
        description: "string",
        project: "string",
        stage: "string",
    });
    
    type: gcp:projects:IAMCustomRole
    properties:
        description: string
        permissions:
            - string
        project: string
        roleId: string
        stage: string
        title: string
    

    IAMCustomRole Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The IAMCustomRole resource accepts the following input properties:

    Permissions List<string>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    RoleId string
    The camel case role id to use for this role. Cannot contain - characters.
    Title string
    A human-readable title for the role.
    Description string
    A human-readable description for the role.
    Project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    Stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    Permissions []string
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    RoleId string
    The camel case role id to use for this role. Cannot contain - characters.
    Title string
    A human-readable title for the role.
    Description string
    A human-readable description for the role.
    Project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    Stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    permissions List<String>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    roleId String
    The camel case role id to use for this role. Cannot contain - characters.
    title String
    A human-readable title for the role.
    description String
    A human-readable description for the role.
    project String
    The project that the custom role will be created in. Defaults to the provider project configuration.
    stage String
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    permissions string[]
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    roleId string
    The camel case role id to use for this role. Cannot contain - characters.
    title string
    A human-readable title for the role.
    description string
    A human-readable description for the role.
    project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    permissions Sequence[str]
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    role_id str
    The camel case role id to use for this role. Cannot contain - characters.
    title str
    A human-readable title for the role.
    description str
    A human-readable description for the role.
    project str
    The project that the custom role will be created in. Defaults to the provider project configuration.
    stage str
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    permissions List<String>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    roleId String
    The camel case role id to use for this role. Cannot contain - characters.
    title String
    A human-readable title for the role.
    description String
    A human-readable description for the role.
    project String
    The project that the custom role will be created in. Defaults to the provider project configuration.
    stage String
    The current launch stage of the role. Defaults to GA. List of possible stages is here.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the IAMCustomRole resource produces the following output properties:

    Deleted bool
    (Optional) The current deleted state of the role.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    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.
    Deleted bool
    (Optional) The current deleted state of the role.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    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.
    deleted Boolean
    (Optional) The current deleted state of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    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.
    deleted boolean
    (Optional) The current deleted state of the role.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    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.
    deleted bool
    (Optional) The current deleted state of the role.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    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.
    deleted Boolean
    (Optional) The current deleted state of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    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.

    Look up Existing IAMCustomRole Resource

    Get an existing IAMCustomRole 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?: IAMCustomRoleState, opts?: CustomResourceOptions): IAMCustomRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            deleted: Optional[bool] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            permissions: Optional[Sequence[str]] = None,
            project: Optional[str] = None,
            role_id: Optional[str] = None,
            stage: Optional[str] = None,
            title: Optional[str] = None) -> IAMCustomRole
    func GetIAMCustomRole(ctx *Context, name string, id IDInput, state *IAMCustomRoleState, opts ...ResourceOption) (*IAMCustomRole, error)
    public static IAMCustomRole Get(string name, Input<string> id, IAMCustomRoleState? state, CustomResourceOptions? opts = null)
    public static IAMCustomRole get(String name, Output<String> id, IAMCustomRoleState 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.
    The following state arguments are supported:
    Deleted bool
    (Optional) The current deleted state of the role.
    Description string
    A human-readable description for the role.
    Name string
    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.
    Permissions List<string>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    Project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    RoleId string
    The camel case role id to use for this role. Cannot contain - characters.
    Stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    Title string
    A human-readable title for the role.
    Deleted bool
    (Optional) The current deleted state of the role.
    Description string
    A human-readable description for the role.
    Name string
    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.
    Permissions []string
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    Project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    RoleId string
    The camel case role id to use for this role. Cannot contain - characters.
    Stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    Title string
    A human-readable title for the role.
    deleted Boolean
    (Optional) The current deleted state of the role.
    description String
    A human-readable description for the role.
    name String
    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.
    permissions List<String>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    project String
    The project that the custom role will be created in. Defaults to the provider project configuration.
    roleId String
    The camel case role id to use for this role. Cannot contain - characters.
    stage String
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    title String
    A human-readable title for the role.
    deleted boolean
    (Optional) The current deleted state of the role.
    description string
    A human-readable description for the role.
    name string
    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.
    permissions string[]
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    project string
    The project that the custom role will be created in. Defaults to the provider project configuration.
    roleId string
    The camel case role id to use for this role. Cannot contain - characters.
    stage string
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    title string
    A human-readable title for the role.
    deleted bool
    (Optional) The current deleted state of the role.
    description str
    A human-readable description for the role.
    name str
    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.
    permissions Sequence[str]
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    project str
    The project that the custom role will be created in. Defaults to the provider project configuration.
    role_id str
    The camel case role id to use for this role. Cannot contain - characters.
    stage str
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    title str
    A human-readable title for the role.
    deleted Boolean
    (Optional) The current deleted state of the role.
    description String
    A human-readable description for the role.
    name String
    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.
    permissions List<String>
    The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
    project String
    The project that the custom role will be created in. Defaults to the provider project configuration.
    roleId String
    The camel case role id to use for this role. Cannot contain - characters.
    stage String
    The current launch stage of the role. Defaults to GA. List of possible stages is here.
    title String
    A human-readable title for the role.

    Import

    Custom Roles can be imported using any of these accepted formats:

    • projects/{{project}}/roles/{{role_id}}

    • {{project}}/{{role_id}}

    • {{role_id}}

    When using the pulumi import command, Custom Roles can be imported using one of the formats above. For example:

    $ pulumi import gcp:projects/iAMCustomRole:IAMCustomRole default projects/{{project}}/roles/{{role_id}}
    
    $ pulumi import gcp:projects/iAMCustomRole:IAMCustomRole default {{project}}/{{role_id}}
    
    $ pulumi import gcp:projects/iAMCustomRole:IAMCustomRole default {{role_id}}
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi