Alibaba Cloud
ControlPolicyAttachment
Provides a Resource Manager Control Policy Attachment resource.
For information about Resource Manager Control Policy Attachment and how to use it, see What is Control Policy Attachment.
NOTE: Available in v1.120.0+.
Example Usage
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
// Enable the control policy
var exampleResourceDirectory = new AliCloud.ResourceManager.ResourceDirectory("exampleResourceDirectory", new AliCloud.ResourceManager.ResourceDirectoryArgs
{
Status = "Enabled",
});
var exampleControlPolicy = new AliCloud.ResourceManager.ControlPolicy("exampleControlPolicy", new AliCloud.ResourceManager.ControlPolicyArgs
{
ControlPolicyName = "tf-testAccName",
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""
}
]
}
",
});
var exampleFolder = new AliCloud.ResourceManager.Folder("exampleFolder", new AliCloud.ResourceManager.FolderArgs
{
FolderName = "tf-testAccName",
});
var exampleControlPolicyAttachment = new AliCloud.ResourceManager.ControlPolicyAttachment("exampleControlPolicyAttachment", new AliCloud.ResourceManager.ControlPolicyAttachmentArgs
{
PolicyId = exampleControlPolicy.Id,
TargetId = exampleFolder.Id,
}, new CustomResourceOptions
{
DependsOn =
{
exampleResourceDirectory,
},
});
}
}
package main
import (
"fmt"
"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 {
exampleResourceDirectory, err := resourcemanager.NewResourceDirectory(ctx, "exampleResourceDirectory", &resourcemanager.ResourceDirectoryArgs{
Status: pulumi.String("Enabled"),
})
if err != nil {
return err
}
exampleControlPolicy, err := resourcemanager.NewControlPolicy(ctx, "exampleControlPolicy", &resourcemanager.ControlPolicyArgs{
ControlPolicyName: pulumi.String("tf-testAccName"),
Description: pulumi.String("tf-testAccRDControlPolicy"),
EffectScope: pulumi.String("RAM"),
PolicyDocument: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", " {\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")),
})
if err != nil {
return err
}
exampleFolder, err := resourcemanager.NewFolder(ctx, "exampleFolder", &resourcemanager.FolderArgs{
FolderName: pulumi.String("tf-testAccName"),
})
if err != nil {
return err
}
_, err = resourcemanager.NewControlPolicyAttachment(ctx, "exampleControlPolicyAttachment", &resourcemanager.ControlPolicyAttachmentArgs{
PolicyId: exampleControlPolicy.ID(),
TargetId: exampleFolder.ID(),
}, pulumi.DependsOn([]pulumi.Resource{
exampleResourceDirectory,
}))
if err != nil {
return err
}
return nil
})
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
# Enable the control policy
example_resource_directory = alicloud.resourcemanager.ResourceDirectory("exampleResourceDirectory", status="Enabled")
example_control_policy = alicloud.resourcemanager.ControlPolicy("exampleControlPolicy",
control_policy_name="tf-testAccName",
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"
}
]
}
""")
example_folder = alicloud.resourcemanager.Folder("exampleFolder", folder_name="tf-testAccName")
example_control_policy_attachment = alicloud.resourcemanager.ControlPolicyAttachment("exampleControlPolicyAttachment",
policy_id=example_control_policy.id,
target_id=example_folder.id,
opts=pulumi.ResourceOptions(depends_on=[example_resource_directory]))
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
// Enable the control policy
const exampleResourceDirectory = new alicloud.resourcemanager.ResourceDirectory("exampleResourceDirectory", {status: "Enabled"});
const exampleControlPolicy = new alicloud.resourcemanager.ControlPolicy("exampleControlPolicy", {
controlPolicyName: "tf-testAccName",
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"
}
]
}
`,
});
const exampleFolder = new alicloud.resourcemanager.Folder("exampleFolder", {folderName: "tf-testAccName"});
const exampleControlPolicyAttachment = new alicloud.resourcemanager.ControlPolicyAttachment("exampleControlPolicyAttachment", {
policyId: exampleControlPolicy.id,
targetId: exampleFolder.id,
}, {
dependsOn: [exampleResourceDirectory],
});
Coming soon!
Create a ControlPolicyAttachment Resource
new ControlPolicyAttachment(name: string, args: ControlPolicyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def ControlPolicyAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_id: Optional[str] = None,
target_id: Optional[str] = None)
@overload
def ControlPolicyAttachment(resource_name: str,
args: ControlPolicyAttachmentArgs,
opts: Optional[ResourceOptions] = None)
func NewControlPolicyAttachment(ctx *Context, name string, args ControlPolicyAttachmentArgs, opts ...ResourceOption) (*ControlPolicyAttachment, error)
public ControlPolicyAttachment(string name, ControlPolicyAttachmentArgs args, CustomResourceOptions? opts = null)
public ControlPolicyAttachment(String name, ControlPolicyAttachmentArgs args)
public ControlPolicyAttachment(String name, ControlPolicyAttachmentArgs args, CustomResourceOptions options)
type: alicloud:resourcemanager:ControlPolicyAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ControlPolicyAttachmentArgs
- 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 ControlPolicyAttachmentArgs
- 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 ControlPolicyAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ControlPolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ControlPolicyAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ControlPolicyAttachment 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 ControlPolicyAttachment resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the ControlPolicyAttachment 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 an Existing ControlPolicyAttachment Resource
Get an existing ControlPolicyAttachment 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?: ControlPolicyAttachmentState, opts?: CustomResourceOptions): ControlPolicyAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
policy_id: Optional[str] = None,
target_id: Optional[str] = None) -> ControlPolicyAttachment
func GetControlPolicyAttachment(ctx *Context, name string, id IDInput, state *ControlPolicyAttachmentState, opts ...ResourceOption) (*ControlPolicyAttachment, error)
public static ControlPolicyAttachment Get(string name, Input<string> id, ControlPolicyAttachmentState? state, CustomResourceOptions? opts = null)
public static ControlPolicyAttachment get(String name, Output<String> id, ControlPolicyAttachmentState 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.
Import
Resource Manager Control Policy Attachment can be imported using the id, e.g.
$ pulumi import alicloud:resourcemanager/controlPolicyAttachment:ControlPolicyAttachment example <policy_id>:<target_id>
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.