1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. resourcemanager
  5. PolicyVersion
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.resourcemanager.PolicyVersion

Explore with Pulumi AI

Provides a Resource Manager Policy Version resource. For information about Resource Manager Policy Version and how to use it, see What is Resource Manager Policy Version.

NOTE: Available since v1.84.0.

NOTE: It is not recommended to use this resource management policy version, it is recommended to directly use the policy resource to manage your policy. Please refer to the link for usage resource_manager_policy.

Example Usage

Basic 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 example = new alicloud.resourcemanager.Policy("example", {
    policyName: name,
    policyDocument: `\x09\x09{
\x09\x09\x09"Statement": [{
\x09\x09\x09\x09"Action": ["oss:*"],
\x09\x09\x09\x09"Effect": "Allow",
\x09\x09\x09\x09"Resource": ["acs:oss:*:*:*"]
\x09\x09\x09}],
\x09\x09\x09"Version": "1"
\x09\x09}
`,
});
const examplePolicyVersion = new alicloud.resourcemanager.PolicyVersion("example", {
    policyName: example.policyName,
    policyDocument: `\x09\x09{
\x09\x09\x09"Statement": [{
\x09\x09\x09\x09"Action": ["oss:*"],
\x09\x09\x09\x09"Effect": "Allow",
\x09\x09\x09\x09"Resource": ["acs:oss:*:*:myphotos"]
\x09\x09\x09}],
\x09\x09\x09"Version": "1"
\x09\x09}
`,
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "tfexample"
example = alicloud.resourcemanager.Policy("example",
    policy_name=name,
    policy_document="""\x09\x09{
\x09\x09\x09"Statement": [{
\x09\x09\x09\x09"Action": ["oss:*"],
\x09\x09\x09\x09"Effect": "Allow",
\x09\x09\x09\x09"Resource": ["acs:oss:*:*:*"]
\x09\x09\x09}],
\x09\x09\x09"Version": "1"
\x09\x09}
""")
example_policy_version = alicloud.resourcemanager.PolicyVersion("example",
    policy_name=example.policy_name,
    policy_document="""\x09\x09{
\x09\x09\x09"Statement": [{
\x09\x09\x09\x09"Action": ["oss:*"],
\x09\x09\x09\x09"Effect": "Allow",
\x09\x09\x09\x09"Resource": ["acs:oss:*:*:myphotos"]
\x09\x09\x09}],
\x09\x09\x09"Version": "1"
\x09\x09}
""")
Copy
package main

import (
	"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
		}
		example, err := resourcemanager.NewPolicy(ctx, "example", &resourcemanager.PolicyArgs{
			PolicyName: pulumi.String(name),
			PolicyDocument: pulumi.String(`		{
			"Statement": [{
				"Action": ["oss:*"],
				"Effect": "Allow",
				"Resource": ["acs:oss:*:*:*"]
			}],
			"Version": "1"
		}
`),
		})
		if err != nil {
			return err
		}
		_, err = resourcemanager.NewPolicyVersion(ctx, "example", &resourcemanager.PolicyVersionArgs{
			PolicyName: example.PolicyName,
			PolicyDocument: pulumi.String(`		{
			"Statement": [{
				"Action": ["oss:*"],
				"Effect": "Allow",
				"Resource": ["acs:oss:*:*:myphotos"]
			}],
			"Version": "1"
		}
`),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 example = new AliCloud.ResourceManager.Policy("example", new()
    {
        PolicyName = name,
        PolicyDocument = @"		{
			""Statement"": [{
				""Action"": [""oss:*""],
				""Effect"": ""Allow"",
				""Resource"": [""acs:oss:*:*:*""]
			}],
			""Version"": ""1""
		}
",
    });

    var examplePolicyVersion = new AliCloud.ResourceManager.PolicyVersion("example", new()
    {
        PolicyName = example.PolicyName,
        PolicyDocument = @"		{
			""Statement"": [{
				""Action"": [""oss:*""],
				""Effect"": ""Allow"",
				""Resource"": [""acs:oss:*:*:myphotos""]
			}],
			""Version"": ""1""
		}
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.resourcemanager.Policy;
import com.pulumi.alicloud.resourcemanager.PolicyArgs;
import com.pulumi.alicloud.resourcemanager.PolicyVersion;
import com.pulumi.alicloud.resourcemanager.PolicyVersionArgs;
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");
        var example = new Policy("example", PolicyArgs.builder()
            .policyName(name)
            .policyDocument("""
		{
			"Statement": [{
				"Action": ["oss:*"],
				"Effect": "Allow",
				"Resource": ["acs:oss:*:*:*"]
			}],
			"Version": "1"
		}
            """)
            .build());

        var examplePolicyVersion = new PolicyVersion("examplePolicyVersion", PolicyVersionArgs.builder()
            .policyName(example.policyName())
            .policyDocument("""
		{
			"Statement": [{
				"Action": ["oss:*"],
				"Effect": "Allow",
				"Resource": ["acs:oss:*:*:myphotos"]
			}],
			"Version": "1"
		}
            """)
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: tfexample
resources:
  example:
    type: alicloud:resourcemanager:Policy
    properties:
      policyName: ${name}
      policyDocument: |
        		{
        			"Statement": [{
        				"Action": ["oss:*"],
        				"Effect": "Allow",
        				"Resource": ["acs:oss:*:*:*"]
        			}],
        			"Version": "1"
        		}        
  examplePolicyVersion:
    type: alicloud:resourcemanager:PolicyVersion
    name: example
    properties:
      policyName: ${example.policyName}
      policyDocument: |
        		{
        			"Statement": [{
        				"Action": ["oss:*"],
        				"Effect": "Allow",
        				"Resource": ["acs:oss:*:*:myphotos"]
        			}],
        			"Version": "1"
        		}        
Copy

Create PolicyVersion Resource

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

Constructor syntax

new PolicyVersion(name: string, args: PolicyVersionArgs, opts?: CustomResourceOptions);
@overload
def PolicyVersion(resource_name: str,
                  args: PolicyVersionArgs,
                  opts: Optional[ResourceOptions] = None)

@overload
def PolicyVersion(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  policy_document: Optional[str] = None,
                  policy_name: Optional[str] = None,
                  is_default_version: Optional[bool] = None)
func NewPolicyVersion(ctx *Context, name string, args PolicyVersionArgs, opts ...ResourceOption) (*PolicyVersion, error)
public PolicyVersion(string name, PolicyVersionArgs args, CustomResourceOptions? opts = null)
public PolicyVersion(String name, PolicyVersionArgs args)
public PolicyVersion(String name, PolicyVersionArgs args, CustomResourceOptions options)
type: alicloud:resourcemanager:PolicyVersion
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. PolicyVersionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. PolicyVersionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. PolicyVersionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. PolicyVersionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. PolicyVersionArgs
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 policyVersionResource = new AliCloud.ResourceManager.PolicyVersion("policyVersionResource", new()
{
    PolicyDocument = "string",
    PolicyName = "string",
});
Copy
example, err := resourcemanager.NewPolicyVersion(ctx, "policyVersionResource", &resourcemanager.PolicyVersionArgs{
	PolicyDocument: pulumi.String("string"),
	PolicyName:     pulumi.String("string"),
})
Copy
var policyVersionResource = new PolicyVersion("policyVersionResource", PolicyVersionArgs.builder()
    .policyDocument("string")
    .policyName("string")
    .build());
Copy
policy_version_resource = alicloud.resourcemanager.PolicyVersion("policyVersionResource",
    policy_document="string",
    policy_name="string")
Copy
const policyVersionResource = new alicloud.resourcemanager.PolicyVersion("policyVersionResource", {
    policyDocument: "string",
    policyName: "string",
});
Copy
type: alicloud:resourcemanager:PolicyVersion
properties:
    policyDocument: string
    policyName: string
Copy

PolicyVersion Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The PolicyVersion resource accepts the following input properties:

PolicyDocument
This property is required.
Changes to this property will trigger replacement.
string
The content of the policy. The content must be 1 to 2,048 characters in length.
PolicyName
This property is required.
Changes to this property will trigger replacement.
string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
IsDefaultVersion bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

PolicyDocument
This property is required.
Changes to this property will trigger replacement.
string
The content of the policy. The content must be 1 to 2,048 characters in length.
PolicyName
This property is required.
Changes to this property will trigger replacement.
string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
IsDefaultVersion bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument
This property is required.
Changes to this property will trigger replacement.
String
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName
This property is required.
Changes to this property will trigger replacement.
String
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion Boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument
This property is required.
Changes to this property will trigger replacement.
string
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName
This property is required.
Changes to this property will trigger replacement.
string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policy_document
This property is required.
Changes to this property will trigger replacement.
str
The content of the policy. The content must be 1 to 2,048 characters in length.
policy_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
is_default_version bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument
This property is required.
Changes to this property will trigger replacement.
String
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName
This property is required.
Changes to this property will trigger replacement.
String
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion Boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing PolicyVersion Resource

Get an existing PolicyVersion 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?: PolicyVersionState, opts?: CustomResourceOptions): PolicyVersion
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        is_default_version: Optional[bool] = None,
        policy_document: Optional[str] = None,
        policy_name: Optional[str] = None) -> PolicyVersion
func GetPolicyVersion(ctx *Context, name string, id IDInput, state *PolicyVersionState, opts ...ResourceOption) (*PolicyVersion, error)
public static PolicyVersion Get(string name, Input<string> id, PolicyVersionState? state, CustomResourceOptions? opts = null)
public static PolicyVersion get(String name, Output<String> id, PolicyVersionState state, CustomResourceOptions options)
resources:  _:    type: alicloud:resourcemanager:PolicyVersion    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
IsDefaultVersion bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

PolicyDocument Changes to this property will trigger replacement. string
The content of the policy. The content must be 1 to 2,048 characters in length.
PolicyName Changes to this property will trigger replacement. string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
IsDefaultVersion bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

PolicyDocument Changes to this property will trigger replacement. string
The content of the policy. The content must be 1 to 2,048 characters in length.
PolicyName Changes to this property will trigger replacement. string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion Boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument Changes to this property will trigger replacement. String
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName Changes to this property will trigger replacement. String
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument Changes to this property will trigger replacement. string
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName Changes to this property will trigger replacement. string
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
is_default_version bool
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policy_document Changes to this property will trigger replacement. str
The content of the policy. The content must be 1 to 2,048 characters in length.
policy_name Changes to this property will trigger replacement. str
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
isDefaultVersion Boolean
Specifies whether to set the policy version as the default version. Default to false.

Deprecated: Field 'is_default_version' has been deprecated from provider version 1.90.0

policyDocument Changes to this property will trigger replacement. String
The content of the policy. The content must be 1 to 2,048 characters in length.
policyName Changes to this property will trigger replacement. String
The name of the policy. Name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).

Import

Resource Manager Policy Version can be imported using the id, e.g.

$ pulumi import alicloud:resourcemanager/policyVersion:PolicyVersion example tftest:v2
Copy

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.