1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. resourcemanager
  5. Role
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

alicloud.resourcemanager.Role

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides a Resource Manager role resource. Members are resource containers in the resource directory, which can physically isolate resources to form an independent resource grouping unit. You can create members in the resource folder to manage them in a unified manner. For information about Resource Manager role and how to use it, see What is Resource Manager role.

    NOTE: Available since v1.82.0.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "tfexample";
    const default = alicloud.getAccount({});
    const example = new alicloud.resourcemanager.Role("example", {
        roleName: name,
        assumeRolePolicyDocument: _default.then(_default => `     {
              "Statement": [
                   {
                        "Action": "sts:AssumeRole",
                        "Effect": "Allow",
                        "Principal": {
                            "RAM":[
                                    "acs:ram::${_default.id}:root"
                            ]
                        }
                    }
              ],
              "Version": "1"
         }
    `),
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tfexample"
    default = alicloud.get_account()
    example = alicloud.resourcemanager.Role("example",
        role_name=name,
        assume_role_policy_document=f"""     {{
              "Statement": [
                   {{
                        "Action": "sts:AssumeRole",
                        "Effect": "Allow",
                        "Principal": {{
                            "RAM":[
                                    "acs:ram::{default.id}:root"
                            ]
                        }}
                    }}
              ],
              "Version": "1"
         }}
    """)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "tfexample"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := alicloud.GetAccount(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		_, err = resourcemanager.NewRole(ctx, "example", &resourcemanager.RoleArgs{
    			RoleName: pulumi.String(name),
    			AssumeRolePolicyDocument: pulumi.String(fmt.Sprintf(`     {
              "Statement": [
                   {
                        "Action": "sts:AssumeRole",
                        "Effect": "Allow",
                        "Principal": {
                            "RAM":[
                                    "acs:ram::%v:root"
                            ]
                        }
                    }
              ],
              "Version": "1"
         }
    `, _default.Id)),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "tfexample";
        var @default = AliCloud.GetAccount.Invoke();
    
        var example = new AliCloud.ResourceManager.Role("example", new()
        {
            RoleName = name,
            AssumeRolePolicyDocument = @default.Apply(@default => @$"     {{
              ""Statement"": [
                   {{
                        ""Action"": ""sts:AssumeRole"",
                        ""Effect"": ""Allow"",
                        ""Principal"": {{
                            ""RAM"":[
                                    ""acs:ram::{@default.Apply(getAccountResult => getAccountResult.Id)}:root""
                            ]
                        }}
                    }}
              ],
              ""Version"": ""1""
         }}
    "),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.AlicloudFunctions;
    import com.pulumi.alicloud.resourcemanager.Role;
    import com.pulumi.alicloud.resourcemanager.RoleArgs;
    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 config = ctx.config();
            final var name = config.get("name").orElse("tfexample");
            final var default = AlicloudFunctions.getAccount();
    
            var example = new Role("example", RoleArgs.builder()
                .roleName(name)
                .assumeRolePolicyDocument("""
         {
              "Statement": [
                   {
                        "Action": "sts:AssumeRole",
                        "Effect": "Allow",
                        "Principal": {
                            "RAM":[
                                    "acs:ram::%s:root"
                            ]
                        }
                    }
              ],
              "Version": "1"
         }
    ", default_.id()))
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: tfexample
    resources:
      example:
        type: alicloud:resourcemanager:Role
        properties:
          roleName: ${name}
          assumeRolePolicyDocument: |2
                 {
                      "Statement": [
                           {
                                "Action": "sts:AssumeRole",
                                "Effect": "Allow",
                                "Principal": {
                                    "RAM":[
                                            "acs:ram::${default.id}:root"
                                    ]
                                }
                            }
                      ],
                      "Version": "1"
                 }
    variables:
      default:
        fn::invoke:
          Function: alicloud:getAccount
          Arguments: {}
    

    Create Role Resource

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

    Constructor syntax

    new Role(name: string, args: RoleArgs, opts?: CustomResourceOptions);
    @overload
    def Role(resource_name: str,
             args: RoleArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def Role(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             assume_role_policy_document: Optional[str] = None,
             role_name: Optional[str] = None,
             description: Optional[str] = None,
             max_session_duration: Optional[int] = None)
    func NewRole(ctx *Context, name string, args RoleArgs, opts ...ResourceOption) (*Role, error)
    public Role(string name, RoleArgs args, CustomResourceOptions? opts = null)
    public Role(String name, RoleArgs args)
    public Role(String name, RoleArgs args, CustomResourceOptions options)
    
    type: alicloud:resourcemanager:Role
    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 RoleArgs
    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 RoleArgs
    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 RoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RoleArgs
    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 alicloudRoleResource = new AliCloud.ResourceManager.Role("alicloudRoleResource", new()
    {
        AssumeRolePolicyDocument = "string",
        RoleName = "string",
        Description = "string",
        MaxSessionDuration = 0,
    });
    
    example, err := resourcemanager.NewRole(ctx, "alicloudRoleResource", &resourcemanager.RoleArgs{
    	AssumeRolePolicyDocument: pulumi.String("string"),
    	RoleName:                 pulumi.String("string"),
    	Description:              pulumi.String("string"),
    	MaxSessionDuration:       pulumi.Int(0),
    })
    
    var alicloudRoleResource = new Role("alicloudRoleResource", RoleArgs.builder()
        .assumeRolePolicyDocument("string")
        .roleName("string")
        .description("string")
        .maxSessionDuration(0)
        .build());
    
    alicloud_role_resource = alicloud.resourcemanager.Role("alicloudRoleResource",
        assume_role_policy_document="string",
        role_name="string",
        description="string",
        max_session_duration=0)
    
    const alicloudRoleResource = new alicloud.resourcemanager.Role("alicloudRoleResource", {
        assumeRolePolicyDocument: "string",
        roleName: "string",
        description: "string",
        maxSessionDuration: 0,
    });
    
    type: alicloud:resourcemanager:Role
    properties:
        assumeRolePolicyDocument: string
        description: string
        maxSessionDuration: 0
        roleName: string
    

    Role 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 Role resource accepts the following input properties:

    AssumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    RoleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    Description string
    The description of the Resource Manager role.
    MaxSessionDuration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    AssumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    RoleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    Description string
    The description of the Resource Manager role.
    MaxSessionDuration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    assumeRolePolicyDocument String
    The content of the permissions strategy that plays a role.
    roleName String
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    description String
    The description of the Resource Manager role.
    maxSessionDuration Integer
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    assumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    roleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    description string
    The description of the Resource Manager role.
    maxSessionDuration number
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    assume_role_policy_document str
    The content of the permissions strategy that plays a role.
    role_name str
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    description str
    The description of the Resource Manager role.
    max_session_duration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    assumeRolePolicyDocument String
    The content of the permissions strategy that plays a role.
    roleName String
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    description String
    The description of the Resource Manager role.
    maxSessionDuration Number
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.

    Outputs

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

    Arn string
    The resource descriptor of the role.
    Id string
    The provider-assigned unique ID for this managed resource.
    RoleId string
    This ID of Resource Manager role. The value is set to role_name.
    UpdateDate string
    Role update time.
    Arn string
    The resource descriptor of the role.
    Id string
    The provider-assigned unique ID for this managed resource.
    RoleId string
    This ID of Resource Manager role. The value is set to role_name.
    UpdateDate string
    Role update time.
    arn String
    The resource descriptor of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    roleId String
    This ID of Resource Manager role. The value is set to role_name.
    updateDate String
    Role update time.
    arn string
    The resource descriptor of the role.
    id string
    The provider-assigned unique ID for this managed resource.
    roleId string
    This ID of Resource Manager role. The value is set to role_name.
    updateDate string
    Role update time.
    arn str
    The resource descriptor of the role.
    id str
    The provider-assigned unique ID for this managed resource.
    role_id str
    This ID of Resource Manager role. The value is set to role_name.
    update_date str
    Role update time.
    arn String
    The resource descriptor of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    roleId String
    This ID of Resource Manager role. The value is set to role_name.
    updateDate String
    Role update time.

    Look up Existing Role Resource

    Get an existing Role 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?: RoleState, opts?: CustomResourceOptions): Role
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            assume_role_policy_document: Optional[str] = None,
            description: Optional[str] = None,
            max_session_duration: Optional[int] = None,
            role_id: Optional[str] = None,
            role_name: Optional[str] = None,
            update_date: Optional[str] = None) -> Role
    func GetRole(ctx *Context, name string, id IDInput, state *RoleState, opts ...ResourceOption) (*Role, error)
    public static Role Get(string name, Input<string> id, RoleState? state, CustomResourceOptions? opts = null)
    public static Role get(String name, Output<String> id, RoleState 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:
    Arn string
    The resource descriptor of the role.
    AssumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    Description string
    The description of the Resource Manager role.
    MaxSessionDuration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    RoleId string
    This ID of Resource Manager role. The value is set to role_name.
    RoleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    UpdateDate string
    Role update time.
    Arn string
    The resource descriptor of the role.
    AssumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    Description string
    The description of the Resource Manager role.
    MaxSessionDuration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    RoleId string
    This ID of Resource Manager role. The value is set to role_name.
    RoleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    UpdateDate string
    Role update time.
    arn String
    The resource descriptor of the role.
    assumeRolePolicyDocument String
    The content of the permissions strategy that plays a role.
    description String
    The description of the Resource Manager role.
    maxSessionDuration Integer
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    roleId String
    This ID of Resource Manager role. The value is set to role_name.
    roleName String
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    updateDate String
    Role update time.
    arn string
    The resource descriptor of the role.
    assumeRolePolicyDocument string
    The content of the permissions strategy that plays a role.
    description string
    The description of the Resource Manager role.
    maxSessionDuration number
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    roleId string
    This ID of Resource Manager role. The value is set to role_name.
    roleName string
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    updateDate string
    Role update time.
    arn str
    The resource descriptor of the role.
    assume_role_policy_document str
    The content of the permissions strategy that plays a role.
    description str
    The description of the Resource Manager role.
    max_session_duration int
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    role_id str
    This ID of Resource Manager role. The value is set to role_name.
    role_name str
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    update_date str
    Role update time.
    arn String
    The resource descriptor of the role.
    assumeRolePolicyDocument String
    The content of the permissions strategy that plays a role.
    description String
    The description of the Resource Manager role.
    maxSessionDuration Number
    Role maximum session time. Valid values: [3600-43200]. Default to 3600.
    roleId String
    This ID of Resource Manager role. The value is set to role_name.
    roleName String
    Role Name. The length is 1 ~ 64 characters, which can include English letters, numbers, dots "." and dashes "-".
    updateDate String
    Role update time.

    Import

    Resource Manager can be imported using the id or role_name, e.g.

    $ pulumi import alicloud:resourcemanager/role:Role example testrd
    

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

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi