1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. resourcemanager
  5. Policy
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

alicloud.resourcemanager.Policy

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

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

    NOTE: Available since v1.83.0.

    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: `		{
    			"Statement": [{
    				"Action": ["oss:*"],
    				"Effect": "Allow",
    				"Resource": ["acs:oss:*:*:*"]
    			}],
    			"Version": "1"
    		}
    `,
    });
    
    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="""		{
    			"Statement": [{
    				"Action": ["oss:*"],
    				"Effect": "Allow",
    				"Resource": ["acs:oss:*:*:*"]
    			}],
    			"Version": "1"
    		}
    """)
    
    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
    		}
    		_, 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
    		}
    		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 example = new AliCloud.ResourceManager.Policy("example", new()
        {
            PolicyName = name,
            PolicyDocument = @"		{
    			""Statement"": [{
    				""Action"": [""oss:*""],
    				""Effect"": ""Allow"",
    				""Resource"": [""acs:oss:*:*:*""]
    			}],
    			""Version"": ""1""
    		}
    ",
        });
    
    });
    
    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 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());
    
        }
    }
    
    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"
            		}        
    

    Create Policy Resource

    new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
    @overload
    def Policy(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               default_version: Optional[str] = None,
               description: Optional[str] = None,
               policy_document: Optional[str] = None,
               policy_name: Optional[str] = None)
    @overload
    def Policy(resource_name: str,
               args: PolicyArgs,
               opts: Optional[ResourceOptions] = None)
    func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
    public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
    public Policy(String name, PolicyArgs args)
    public Policy(String name, PolicyArgs args, CustomResourceOptions options)
    
    type: alicloud:resourcemanager:Policy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args PolicyArgs
    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 PolicyArgs
    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 PolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    PolicyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    PolicyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    DefaultVersion string
    The version of the policy. Default to v1.

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

    Description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    PolicyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    PolicyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    DefaultVersion string
    The version of the policy. Default to v1.

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

    Description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument String
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName String
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    defaultVersion String
    The version of the policy. Default to v1.

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

    description String
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    defaultVersion string
    The version of the policy. Default to v1.

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

    description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policy_document str
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policy_name str
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    default_version str
    The version of the policy. Default to v1.

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

    description str
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument String
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName String
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    defaultVersion String
    The version of the policy. Default to v1.

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

    description String
    The description of the policy. The description must be 1 to 1,024 characters in length.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    PolicyType string
    The type of the policy. Valid values: Custom, System.
    Id string
    The provider-assigned unique ID for this managed resource.
    PolicyType string
    The type of the policy. Valid values: Custom, System.
    id String
    The provider-assigned unique ID for this managed resource.
    policyType String
    The type of the policy. Valid values: Custom, System.
    id string
    The provider-assigned unique ID for this managed resource.
    policyType string
    The type of the policy. Valid values: Custom, System.
    id str
    The provider-assigned unique ID for this managed resource.
    policy_type str
    The type of the policy. Valid values: Custom, System.
    id String
    The provider-assigned unique ID for this managed resource.
    policyType String
    The type of the policy. Valid values: Custom, System.

    Look up Existing Policy Resource

    Get an existing Policy 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?: PolicyState, opts?: CustomResourceOptions): Policy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            default_version: Optional[str] = None,
            description: Optional[str] = None,
            policy_document: Optional[str] = None,
            policy_name: Optional[str] = None,
            policy_type: Optional[str] = None) -> Policy
    func GetPolicy(ctx *Context, name string, id IDInput, state *PolicyState, opts ...ResourceOption) (*Policy, error)
    public static Policy Get(string name, Input<string> id, PolicyState? state, CustomResourceOptions? opts = null)
    public static Policy get(String name, Output<String> id, PolicyState 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:
    DefaultVersion string
    The version of the policy. Default to v1.

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

    Description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    PolicyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    PolicyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    PolicyType string
    The type of the policy. Valid values: Custom, System.
    DefaultVersion string
    The version of the policy. Default to v1.

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

    Description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    PolicyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    PolicyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    PolicyType string
    The type of the policy. Valid values: Custom, System.
    defaultVersion String
    The version of the policy. Default to v1.

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

    description String
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument String
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName String
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    policyType String
    The type of the policy. Valid values: Custom, System.
    defaultVersion string
    The version of the policy. Default to v1.

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

    description string
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument string
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName string
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    policyType string
    The type of the policy. Valid values: Custom, System.
    default_version str
    The version of the policy. Default to v1.

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

    description str
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policy_document str
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policy_name str
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    policy_type str
    The type of the policy. Valid values: Custom, System.
    defaultVersion String
    The version of the policy. Default to v1.

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

    description String
    The description of the policy. The description must be 1 to 1,024 characters in length.
    policyDocument String
    The content of the policy. The content must be 1 to 2,048 characters in length.
    policyName String
    The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
    policyType String
    The type of the policy. Valid values: Custom, System.

    Import

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

    $ pulumi import alicloud:resourcemanager/policy:Policy example abc12345
    

    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.51.0 published on Saturday, Mar 23, 2024 by Pulumi