PolicyAttachment

class PolicyAttachment : KotlinCustomResource

Provides a Tag Policy Attachment resource to attaches a policy to an object. After you attach a tag policy to an object. For information about Tag Policy Attachment and how to use it, see What is Policy Attachment.

NOTE: Available since v1.204.0.

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.tag.Policy;
import com.pulumi.alicloud.tag.PolicyArgs;
import com.pulumi.alicloud.tag.PolicyAttachment;
import com.pulumi.alicloud.tag.PolicyAttachmentArgs;
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("tf-example");
final var default = AlicloudFunctions.getAccount();
var examplePolicy = new Policy("examplePolicy", PolicyArgs.builder()
.policyName(name)
.policyDesc(name)
.userType("USER")
.policyContent("""
{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}
""")
.build());
var examplePolicyAttachment = new PolicyAttachment("examplePolicyAttachment", PolicyAttachmentArgs.builder()
.policyId(examplePolicy.id())
.targetId(default_.id())
.targetType("USER")
.build());
}
}

Import

Tag Policy Attachment can be imported using the id, e.g.

$ pulumi import alicloud:tag/policyAttachment:PolicyAttachment example <policy_id>:<target_id>:<target_type>

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val policyId: Output<String>

The ID of the tag policy.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val targetId: Output<String>

The ID of the object.

Link copied to clipboard
val targetType: Output<String>

The type of the object. Valid values: USER, ROOT, FOLDER, ACCOUNT.

Link copied to clipboard
val urn: Output<String>