Alibaba Cloud v3.88.1 published on Saturday, Nov 8, 2025 by Pulumi
Alibaba Cloud v3.88.1 published on Saturday, Nov 8, 2025 by Pulumi
This data source provides the RAM Policies of the current Alibaba Cloud user.
NOTE: Available since v1.0.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultPolicy = new alicloud.ram.Policy("default", {
policyName: `${name}-${_default.result}`,
description: `${name}-${_default.result}`,
force: true,
policyDocument: ` {
\\"Statement\\": [
{
\\"Effect\\": \\"Allow\\",
\\"Action\\": \\"*\\",
\\"Resource\\": \\"*\\"
}
],
\\"Version\\": \\"1\\"
}
`,
tags: {
Created: "TF",
For: "Policy",
},
});
const ids = alicloud.ram.getPoliciesOutput({
ids: [defaultPolicy.id],
});
export const ramPoliciesId0 = ids.apply(ids => ids.policies?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = random.index.Integer("default",
min=10000,
max=99999)
default_policy = alicloud.ram.Policy("default",
policy_name=f"{name}-{default['result']}",
description=f"{name}-{default['result']}",
force=True,
policy_document=""" {
\"Statement\": [
{
\"Effect\": \"Allow\",
\"Action\": \"*\",
\"Resource\": \"*\"
}
],
\"Version\": \"1\"
}
""",
tags={
"Created": "TF",
"For": "Policy",
})
ids = alicloud.ram.get_policies_output(ids=[default_policy.id])
pulumi.export("ramPoliciesId0", ids.policies[0].id)
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ram"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"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 := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultPolicy, err := ram.NewPolicy(ctx, "default", &ram.PolicyArgs{
PolicyName: pulumi.Sprintf("%v-%v", name, _default.Result),
Description: pulumi.Sprintf("%v-%v", name, _default.Result),
Force: pulumi.Bool(true),
PolicyDocument: pulumi.String(` {
\"Statement\": [
{
\"Effect\": \"Allow\",
\"Action\": \"*\",
\"Resource\": \"*\"
}
],
\"Version\": \"1\"
}
`),
Tags: pulumi.StringMap{
"Created": pulumi.String("TF"),
"For": pulumi.String("Policy"),
},
})
if err != nil {
return err
}
ids := ram.GetPoliciesOutput(ctx, ram.GetPoliciesOutputArgs{
Ids: pulumi.StringArray{
defaultPolicy.ID(),
},
}, nil)
ctx.Export("ramPoliciesId0", ids.ApplyT(func(ids ram.GetPoliciesResult) (*string, error) {
return &ids.Policies[0].Id, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultPolicy = new AliCloud.Ram.Policy("default", new()
{
PolicyName = $"{name}-{@default.Result}",
Description = $"{name}-{@default.Result}",
Force = true,
PolicyDocument = @" {
\""Statement\"": [
{
\""Effect\"": \""Allow\"",
\""Action\"": \""*\"",
\""Resource\"": \""*\""
}
],
\""Version\"": \""1\""
}
",
Tags =
{
{ "Created", "TF" },
{ "For", "Policy" },
},
});
var ids = AliCloud.Ram.GetPolicies.Invoke(new()
{
Ids = new[]
{
defaultPolicy.Id,
},
});
return new Dictionary<string, object?>
{
["ramPoliciesId0"] = ids.Apply(getPoliciesResult => getPoliciesResult.Policies[0]?.Id),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.Integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.ram.Policy;
import com.pulumi.alicloud.ram.PolicyArgs;
import com.pulumi.alicloud.ram.RamFunctions;
import com.pulumi.alicloud.ram.inputs.GetPoliciesArgs;
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("terraform-example");
var default_ = new Integer("default", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultPolicy = new Policy("defaultPolicy", PolicyArgs.builder()
.policyName(String.format("%s-%s", name,default_.result()))
.description(String.format("%s-%s", name,default_.result()))
.force(true)
.policyDocument("""
{
\"Statement\": [
{
\"Effect\": \"Allow\",
\"Action\": \"*\",
\"Resource\": \"*\"
}
],
\"Version\": \"1\"
}
""")
.tags(Map.ofEntries(
Map.entry("Created", "TF"),
Map.entry("For", "Policy")
))
.build());
final var ids = RamFunctions.getPolicies(GetPoliciesArgs.builder()
.ids(defaultPolicy.id())
.build());
ctx.export("ramPoliciesId0", ids.applyValue(_ids -> _ids.policies()[0].id()));
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: random:Integer
properties:
min: 10000
max: 99999
defaultPolicy:
type: alicloud:ram:Policy
name: default
properties:
policyName: ${name}-${default.result}
description: ${name}-${default.result}
force: true
policyDocument: |2
{
\"Statement\": [
{
\"Effect\": \"Allow\",
\"Action\": \"*\",
\"Resource\": \"*\"
}
],
\"Version\": \"1\"
}
tags:
Created: TF
For: Policy
variables:
ids:
fn::invoke:
function: alicloud:ram:getPolicies
arguments:
ids:
- ${defaultPolicy.id}
outputs:
ramPoliciesId0: ${ids.policies[0].id}
Using getPolicies
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 getPolicies(args: GetPoliciesArgs, opts?: InvokeOptions): Promise<GetPoliciesResult>
function getPoliciesOutput(args: GetPoliciesOutputArgs, opts?: InvokeOptions): Output<GetPoliciesResult>def get_policies(enable_details: Optional[bool] = None,
group_name: Optional[str] = None,
ids: Optional[Sequence[str]] = None,
name_regex: Optional[str] = None,
output_file: Optional[str] = None,
role_name: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
type: Optional[str] = None,
user_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetPoliciesResult
def get_policies_output(enable_details: Optional[pulumi.Input[bool]] = None,
group_name: Optional[pulumi.Input[str]] = None,
ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
name_regex: Optional[pulumi.Input[str]] = None,
output_file: Optional[pulumi.Input[str]] = None,
role_name: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
type: Optional[pulumi.Input[str]] = None,
user_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetPoliciesResult]func GetPolicies(ctx *Context, args *GetPoliciesArgs, opts ...InvokeOption) (*GetPoliciesResult, error)
func GetPoliciesOutput(ctx *Context, args *GetPoliciesOutputArgs, opts ...InvokeOption) GetPoliciesResultOutput> Note: This function is named GetPolicies in the Go SDK.
public static class GetPolicies
{
public static Task<GetPoliciesResult> InvokeAsync(GetPoliciesArgs args, InvokeOptions? opts = null)
public static Output<GetPoliciesResult> Invoke(GetPoliciesInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOptions options)
public static Output<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOptions options)
fn::invoke:
function: alicloud:ram/getPolicies:getPolicies
arguments:
# arguments dictionaryThe following arguments are supported:
- Enable
Details bool - Whether to query the detailed list of resource attributes. Default value:
true. - Group
Name string - The name of the user group.
- Ids List<string>
- A list of Policy IDs.
- Name
Regex string - A regex string to filter results by Policy name.
- Output
File string - File name where to save data source results (after running
pulumi preview). - Role
Name string - The name of the RAM role.
- Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Type string
- The type of the policy. Valid values:
SystemandCustom. - User
Name string - The name of the RAM user.
- Enable
Details bool - Whether to query the detailed list of resource attributes. Default value:
true. - Group
Name string - The name of the user group.
- Ids []string
- A list of Policy IDs.
- Name
Regex string - A regex string to filter results by Policy name.
- Output
File string - File name where to save data source results (after running
pulumi preview). - Role
Name string - The name of the RAM role.
- map[string]string
- A mapping of tags to assign to the resource.
- Type string
- The type of the policy. Valid values:
SystemandCustom. - User
Name string - The name of the RAM user.
- enable
Details Boolean - Whether to query the detailed list of resource attributes. Default value:
true. - group
Name String - The name of the user group.
- ids List<String>
- A list of Policy IDs.
- name
Regex String - A regex string to filter results by Policy name.
- output
File String - File name where to save data source results (after running
pulumi preview). - role
Name String - The name of the RAM role.
- Map<String,String>
- A mapping of tags to assign to the resource.
- type String
- The type of the policy. Valid values:
SystemandCustom. - user
Name String - The name of the RAM user.
- enable
Details boolean - Whether to query the detailed list of resource attributes. Default value:
true. - group
Name string - The name of the user group.
- ids string[]
- A list of Policy IDs.
- name
Regex string - A regex string to filter results by Policy name.
- output
File string - File name where to save data source results (after running
pulumi preview). - role
Name string - The name of the RAM role.
- {[key: string]: string}
- A mapping of tags to assign to the resource.
- type string
- The type of the policy. Valid values:
SystemandCustom. - user
Name string - The name of the RAM user.
- enable_
details bool - Whether to query the detailed list of resource attributes. Default value:
true. - group_
name str - The name of the user group.
- ids Sequence[str]
- A list of Policy IDs.
- name_
regex str - A regex string to filter results by Policy name.
- output_
file str - File name where to save data source results (after running
pulumi preview). - role_
name str - The name of the RAM role.
- Mapping[str, str]
- A mapping of tags to assign to the resource.
- type str
- The type of the policy. Valid values:
SystemandCustom. - user_
name str - The name of the RAM user.
- enable
Details Boolean - Whether to query the detailed list of resource attributes. Default value:
true. - group
Name String - The name of the user group.
- ids List<String>
- A list of Policy IDs.
- name
Regex String - A regex string to filter results by Policy name.
- output
File String - File name where to save data source results (after running
pulumi preview). - role
Name String - The name of the RAM role.
- Map<String>
- A mapping of tags to assign to the resource.
- type String
- The type of the policy. Valid values:
SystemandCustom. - user
Name String - The name of the RAM user.
getPolicies Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- Names List<string>
- (Available since v1.42.0) A list of Policy names.
- Policies
List<Pulumi.
Ali Cloud. Ram. Outputs. Get Policies Policy> - A list of Policy. Each element contains the following attributes:
- Enable
Details bool - Group
Name string - Name
Regex string - Output
File string - Role
Name string - Dictionary<string, string>
- (Available since v1.262.1) The tags of the Policy.
- Type string
- The type of the policy.
- User
Name string - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- Names []string
- (Available since v1.42.0) A list of Policy names.
- Policies
[]Get
Policies Policy - A list of Policy. Each element contains the following attributes:
- Enable
Details bool - Group
Name string - Name
Regex string - Output
File string - Role
Name string - map[string]string
- (Available since v1.262.1) The tags of the Policy.
- Type string
- The type of the policy.
- User
Name string - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- names List<String>
- (Available since v1.42.0) A list of Policy names.
- policies
List<Get
Policies Policy> - A list of Policy. Each element contains the following attributes:
- enable
Details Boolean - group
Name String - name
Regex String - output
File String - role
Name String - Map<String,String>
- (Available since v1.262.1) The tags of the Policy.
- type String
- The type of the policy.
- user
Name String - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- names string[]
- (Available since v1.42.0) A list of Policy names.
- policies
Get
Policies Policy[] - A list of Policy. Each element contains the following attributes:
- enable
Details boolean - group
Name string - name
Regex string - output
File string - role
Name string - {[key: string]: string}
- (Available since v1.262.1) The tags of the Policy.
- type string
- The type of the policy.
- user
Name string - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- names Sequence[str]
- (Available since v1.42.0) A list of Policy names.
- policies
Sequence[Get
Policies Policy] - A list of Policy. Each element contains the following attributes:
- enable_
details bool - group_
name str - name_
regex str - output_
file str - role_
name str - Mapping[str, str]
- (Available since v1.262.1) The tags of the Policy.
- type str
- The type of the policy.
- user_
name str - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- names List<String>
- (Available since v1.42.0) A list of Policy names.
- policies List<Property Map>
- A list of Policy. Each element contains the following attributes:
- enable
Details Boolean - group
Name String - name
Regex String - output
File String - role
Name String - Map<String>
- (Available since v1.262.1) The tags of the Policy.
- type String
- The type of the policy.
- user
Name String - (Removed since v1.262.1) Field
user_namehas been removed from provider version 1.262.1.
Supporting Types
GetPoliciesPolicy
- Attachment
Count int - The number of references to the policy.
- Create
Date string - The time when the policy was created.
- Default
Version string - The default version of the policy.
- Description string
- The description of the policy.
- Document string
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - Id string
- (Available since v1.114.0) The ID of the Policy.
- Name string
- The name of the policy.
- Policy
Document string - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - Policy
Name string - (Available since v1.114.0) The name of the policy.
- Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Type string
- The type of the policy. Valid values:
SystemandCustom. - Update
Date string - The time when the policy was modified.
- User
Name string - The name of the RAM user.
- Version
Id string - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
- Attachment
Count int - The number of references to the policy.
- Create
Date string - The time when the policy was created.
- Default
Version string - The default version of the policy.
- Description string
- The description of the policy.
- Document string
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - Id string
- (Available since v1.114.0) The ID of the Policy.
- Name string
- The name of the policy.
- Policy
Document string - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - Policy
Name string - (Available since v1.114.0) The name of the policy.
- map[string]string
- A mapping of tags to assign to the resource.
- Type string
- The type of the policy. Valid values:
SystemandCustom. - Update
Date string - The time when the policy was modified.
- User
Name string - The name of the RAM user.
- Version
Id string - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
- attachment
Count Integer - The number of references to the policy.
- create
Date String - The time when the policy was created.
- default
Version String - The default version of the policy.
- description String
- The description of the policy.
- document String
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - id String
- (Available since v1.114.0) The ID of the Policy.
- name String
- The name of the policy.
- policy
Document String - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - policy
Name String - (Available since v1.114.0) The name of the policy.
- Map<String,String>
- A mapping of tags to assign to the resource.
- type String
- The type of the policy. Valid values:
SystemandCustom. - update
Date String - The time when the policy was modified.
- user
Name String - The name of the RAM user.
- version
Id String - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
- attachment
Count number - The number of references to the policy.
- create
Date string - The time when the policy was created.
- default
Version string - The default version of the policy.
- description string
- The description of the policy.
- document string
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - id string
- (Available since v1.114.0) The ID of the Policy.
- name string
- The name of the policy.
- policy
Document string - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - policy
Name string - (Available since v1.114.0) The name of the policy.
- {[key: string]: string}
- A mapping of tags to assign to the resource.
- type string
- The type of the policy. Valid values:
SystemandCustom. - update
Date string - The time when the policy was modified.
- user
Name string - The name of the RAM user.
- version
Id string - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
- attachment_
count int - The number of references to the policy.
- create_
date str - The time when the policy was created.
- default_
version str - The default version of the policy.
- description str
- The description of the policy.
- document str
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - id str
- (Available since v1.114.0) The ID of the Policy.
- name str
- The name of the policy.
- policy_
document str - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - policy_
name str - (Available since v1.114.0) The name of the policy.
- Mapping[str, str]
- A mapping of tags to assign to the resource.
- type str
- The type of the policy. Valid values:
SystemandCustom. - update_
date str - The time when the policy was modified.
- user_
name str - The name of the RAM user.
- version_
id str - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
- attachment
Count Number - The number of references to the policy.
- create
Date String - The time when the policy was created.
- default
Version String - The default version of the policy.
- description String
- The description of the policy.
- document String
- The document of the policy. Note:
documenttakes effect only ifenable_detailsis set totrue. - id String
- (Available since v1.114.0) The ID of the Policy.
- name String
- The name of the policy.
- policy
Document String - (Available since v1.114.0) The document of the policy. Note:
policy_documenttakes effect only ifenable_detailsis set totrue. - policy
Name String - (Available since v1.114.0) The name of the policy.
- Map<String>
- A mapping of tags to assign to the resource.
- type String
- The type of the policy. Valid values:
SystemandCustom. - update
Date String - The time when the policy was modified.
- user
Name String - The name of the RAM user.
- version
Id String - (Available since v1.114.0) The ID of the default policy version. Note:
version_idtakes effect only ifenable_detailsis set totrue.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.
Alibaba Cloud v3.88.1 published on Saturday, Nov 8, 2025 by Pulumi
