alicloud logo
Alibaba Cloud v3.37.0, May 15 23

alicloud.resourcemanager.ControlPolicy

Explore with Pulumi AI

Provides a Resource Manager Control Policy resource.

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

NOTE: Available in v1.120.0+.

Example Usage

Basic Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var example = new AliCloud.ResourceManager.ControlPolicy("example", new()
    {
        ControlPolicyName = "tf-testAccRDControlPolicy",
        Description = "tf-testAccRDControlPolicy",
        EffectScope = "RAM",
        PolicyDocument = @"  {
    ""Version"": ""1"",
    ""Statement"": [
      {
        ""Effect"": ""Deny"",
        ""Action"": [
          ""ram:UpdateRole"",
          ""ram:DeleteRole"",
          ""ram:AttachPolicyToRole"",
          ""ram:DetachPolicyFromRole""
        ],
        ""Resource"": ""acs:ram:*:*:role/ResourceDirectoryAccountAccessRole""
      }
    ]
  }
  
",
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := resourcemanager.NewControlPolicy(ctx, "example", &resourcemanager.ControlPolicyArgs{
			ControlPolicyName: pulumi.String("tf-testAccRDControlPolicy"),
			Description:       pulumi.String("tf-testAccRDControlPolicy"),
			EffectScope:       pulumi.String("RAM"),
			PolicyDocument:    pulumi.String("  {\n    \"Version\": \"1\",\n    \"Statement\": [\n      {\n        \"Effect\": \"Deny\",\n        \"Action\": [\n          \"ram:UpdateRole\",\n          \"ram:DeleteRole\",\n          \"ram:AttachPolicyToRole\",\n          \"ram:DetachPolicyFromRole\"\n        ],\n        \"Resource\": \"acs:ram:*:*:role/ResourceDirectoryAccountAccessRole\"\n      }\n    ]\n  }\n  \n"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.resourcemanager.ControlPolicy;
import com.pulumi.alicloud.resourcemanager.ControlPolicyArgs;
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 example = new ControlPolicy("example", ControlPolicyArgs.builder()        
            .controlPolicyName("tf-testAccRDControlPolicy")
            .description("tf-testAccRDControlPolicy")
            .effectScope("RAM")
            .policyDocument("""
  {
    "Version": "1",
    "Statement": [
      {
        "Effect": "Deny",
        "Action": [
          "ram:UpdateRole",
          "ram:DeleteRole",
          "ram:AttachPolicyToRole",
          "ram:DetachPolicyFromRole"
        ],
        "Resource": "acs:ram:*:*:role/ResourceDirectoryAccountAccessRole"
      }
    ]
  }
  
            """)
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

example = alicloud.resourcemanager.ControlPolicy("example",
    control_policy_name="tf-testAccRDControlPolicy",
    description="tf-testAccRDControlPolicy",
    effect_scope="RAM",
    policy_document="""  {
    "Version": "1",
    "Statement": [
      {
        "Effect": "Deny",
        "Action": [
          "ram:UpdateRole",
          "ram:DeleteRole",
          "ram:AttachPolicyToRole",
          "ram:DetachPolicyFromRole"
        ],
        "Resource": "acs:ram:*:*:role/ResourceDirectoryAccountAccessRole"
      }
    ]
  }
  
""")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const example = new alicloud.resourcemanager.ControlPolicy("example", {
    controlPolicyName: "tf-testAccRDControlPolicy",
    description: "tf-testAccRDControlPolicy",
    effectScope: "RAM",
    policyDocument: `  {
    "Version": "1",
    "Statement": [
      {
        "Effect": "Deny",
        "Action": [
          "ram:UpdateRole",
          "ram:DeleteRole",
          "ram:AttachPolicyToRole",
          "ram:DetachPolicyFromRole"
        ],
        "Resource": "acs:ram:*:*:role/ResourceDirectoryAccountAccessRole"
      }
    ]
  }
  
`,
});
resources:
  example:
    type: alicloud:resourcemanager:ControlPolicy
    properties:
      controlPolicyName: tf-testAccRDControlPolicy
      description: tf-testAccRDControlPolicy
      effectScope: RAM
      policyDocument: "  {\n    \"Version\": \"1\",\n    \"Statement\": [\n      {\n        \"Effect\": \"Deny\",\n        \"Action\": [\n          \"ram:UpdateRole\",\n          \"ram:DeleteRole\",\n          \"ram:AttachPolicyToRole\",\n          \"ram:DetachPolicyFromRole\"\n        ],\n        \"Resource\": \"acs:ram:*:*:role/ResourceDirectoryAccountAccessRole\"\n      }\n    ]\n  }\n  \n"

Create ControlPolicy Resource

new ControlPolicy(name: string, args: ControlPolicyArgs, opts?: CustomResourceOptions);
@overload
def ControlPolicy(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  control_policy_name: Optional[str] = None,
                  description: Optional[str] = None,
                  effect_scope: Optional[str] = None,
                  policy_document: Optional[str] = None)
@overload
def ControlPolicy(resource_name: str,
                  args: ControlPolicyArgs,
                  opts: Optional[ResourceOptions] = None)
func NewControlPolicy(ctx *Context, name string, args ControlPolicyArgs, opts ...ResourceOption) (*ControlPolicy, error)
public ControlPolicy(string name, ControlPolicyArgs args, CustomResourceOptions? opts = null)
public ControlPolicy(String name, ControlPolicyArgs args)
public ControlPolicy(String name, ControlPolicyArgs args, CustomResourceOptions options)
type: alicloud:resourcemanager:ControlPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args ControlPolicyArgs
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 ControlPolicyArgs
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 ControlPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ControlPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ControlPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

ControlPolicyName string

The name of control policy.

EffectScope string

The effect scope. Valid values RAM.

PolicyDocument string

The policy document of control policy.

Description string

The description of control policy.

ControlPolicyName string

The name of control policy.

EffectScope string

The effect scope. Valid values RAM.

PolicyDocument string

The policy document of control policy.

Description string

The description of control policy.

controlPolicyName String

The name of control policy.

effectScope String

The effect scope. Valid values RAM.

policyDocument String

The policy document of control policy.

description String

The description of control policy.

controlPolicyName string

The name of control policy.

effectScope string

The effect scope. Valid values RAM.

policyDocument string

The policy document of control policy.

description string

The description of control policy.

control_policy_name str

The name of control policy.

effect_scope str

The effect scope. Valid values RAM.

policy_document str

The policy document of control policy.

description str

The description of control policy.

controlPolicyName String

The name of control policy.

effectScope String

The effect scope. Valid values RAM.

policyDocument String

The policy document of control policy.

description String

The description of control policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the ControlPolicy 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 ControlPolicy Resource

Get an existing ControlPolicy 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?: ControlPolicyState, opts?: CustomResourceOptions): ControlPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        control_policy_name: Optional[str] = None,
        description: Optional[str] = None,
        effect_scope: Optional[str] = None,
        policy_document: Optional[str] = None) -> ControlPolicy
func GetControlPolicy(ctx *Context, name string, id IDInput, state *ControlPolicyState, opts ...ResourceOption) (*ControlPolicy, error)
public static ControlPolicy Get(string name, Input<string> id, ControlPolicyState? state, CustomResourceOptions? opts = null)
public static ControlPolicy get(String name, Output<String> id, ControlPolicyState 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:
ControlPolicyName string

The name of control policy.

Description string

The description of control policy.

EffectScope string

The effect scope. Valid values RAM.

PolicyDocument string

The policy document of control policy.

ControlPolicyName string

The name of control policy.

Description string

The description of control policy.

EffectScope string

The effect scope. Valid values RAM.

PolicyDocument string

The policy document of control policy.

controlPolicyName String

The name of control policy.

description String

The description of control policy.

effectScope String

The effect scope. Valid values RAM.

policyDocument String

The policy document of control policy.

controlPolicyName string

The name of control policy.

description string

The description of control policy.

effectScope string

The effect scope. Valid values RAM.

policyDocument string

The policy document of control policy.

control_policy_name str

The name of control policy.

description str

The description of control policy.

effect_scope str

The effect scope. Valid values RAM.

policy_document str

The policy document of control policy.

controlPolicyName String

The name of control policy.

description String

The description of control policy.

effectScope String

The effect scope. Valid values RAM.

policyDocument String

The policy document of control policy.

Import

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

 $ pulumi import alicloud:resourcemanager/controlPolicy:ControlPolicy example <id>

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.