alicloud.tag.Policy
Explore with Pulumi AI
Provides a Tag Policy resource.
For information about Tag Policy and how to use it, see What is Policy.
NOTE: Available since v1.203.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") || "terraform-example";
const example = new alicloud.tag.Policy("example", {
policyName: name,
policyDesc: name,
userType: "USER",
policyContent: "\x09\x09{\"tags\":{\"CostCenter\":{\"tag_value\":{\"@@assign\":[\"Beijing\",\"Shanghai\"]},\"tag_key\":{\"@@assign\":\"CostCenter\"}}}}\n",
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
example = alicloud.tag.Policy("example",
policy_name=name,
policy_desc=name,
user_type="USER",
policy_content="\x09\x09{\"tags\":{\"CostCenter\":{\"tag_value\":{\"@@assign\":[\"Beijing\",\"Shanghai\"]},\"tag_key\":{\"@@assign\":\"CostCenter\"}}}}\n")
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/tag"
"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 := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_, err := tag.NewPolicy(ctx, "example", &tag.PolicyArgs{
PolicyName: pulumi.String(name),
PolicyDesc: pulumi.String(name),
UserType: pulumi.String("USER"),
PolicyContent: pulumi.String(" {\"tags\":{\"CostCenter\":{\"tag_value\":{\"@@assign\":[\"Beijing\",\"Shanghai\"]},\"tag_key\":{\"@@assign\":\"CostCenter\"}}}}\n"),
})
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") ?? "terraform-example";
var example = new AliCloud.Tag.Policy("example", new()
{
PolicyName = name,
PolicyDesc = name,
UserType = "USER",
PolicyContent = @" {""tags"":{""CostCenter"":{""tag_value"":{""@@assign"":[""Beijing"",""Shanghai""]},""tag_key"":{""@@assign"":""CostCenter""}}}}
",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.tag.Policy;
import com.pulumi.alicloud.tag.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("terraform-example");
var example = new Policy("example", PolicyArgs.builder()
.policyName(name)
.policyDesc(name)
.userType("USER")
.policyContent("""
{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}
""")
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
example:
type: alicloud:tag:Policy
properties:
policyName: ${name}
policyDesc: ${name}
userType: USER
policyContent: |
{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}
Create Policy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
@overload
def Policy(resource_name: str,
args: PolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Policy(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_content: Optional[str] = None,
policy_name: Optional[str] = None,
policy_desc: Optional[str] = None,
user_type: Optional[str] = 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:tag:Policy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var examplepolicyResourceResourceFromTagpolicy = new AliCloud.Tag.Policy("examplepolicyResourceResourceFromTagpolicy", new()
{
PolicyContent = "string",
PolicyName = "string",
PolicyDesc = "string",
UserType = "string",
});
example, err := tag.NewPolicy(ctx, "examplepolicyResourceResourceFromTagpolicy", &tag.PolicyArgs{
PolicyContent: pulumi.String("string"),
PolicyName: pulumi.String("string"),
PolicyDesc: pulumi.String("string"),
UserType: pulumi.String("string"),
})
var examplepolicyResourceResourceFromTagpolicy = new Policy("examplepolicyResourceResourceFromTagpolicy", PolicyArgs.builder()
.policyContent("string")
.policyName("string")
.policyDesc("string")
.userType("string")
.build());
examplepolicy_resource_resource_from_tagpolicy = alicloud.tag.Policy("examplepolicyResourceResourceFromTagpolicy",
policy_content="string",
policy_name="string",
policy_desc="string",
user_type="string")
const examplepolicyResourceResourceFromTagpolicy = new alicloud.tag.Policy("examplepolicyResourceResourceFromTagpolicy", {
policyContent: "string",
policyName: "string",
policyDesc: "string",
userType: "string",
});
type: alicloud:tag:Policy
properties:
policyContent: string
policyDesc: string
policyName: string
userType: string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Policy resource accepts the following input properties:
- Policy
Content string - The content of the policy.
- Policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- Policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- User
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- Policy
Content string - The content of the policy.
- Policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- Policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- User
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content String - The content of the policy.
- policy
Name String - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- policy
Desc String - The description of the policy. The description must be 1 to 512 characters in length.
- user
Type String - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content string - The content of the policy.
- policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- user
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- policy_
content str - The content of the policy.
- 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_
desc str - The description of the policy. The description must be 1 to 512 characters in length.
- user_
type str - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content String - The content of the policy.
- policy
Name String - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- policy
Desc String - The description of the policy. The description must be 1 to 512 characters in length.
- user
Type String - The type of the tag policy. Valid values:
USER
,RD
.
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.
- 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 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,
policy_content: Optional[str] = None,
policy_desc: Optional[str] = None,
policy_name: Optional[str] = None,
user_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.
- Policy
Content string - The content of the policy.
- Policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- Policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- User
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- Policy
Content string - The content of the policy.
- Policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- Policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- User
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content String - The content of the policy.
- policy
Desc String - The description of the policy. The description must be 1 to 512 characters in length.
- policy
Name String - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- user
Type String - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content string - The content of the policy.
- policy
Desc string - The description of the policy. The description must be 1 to 512 characters in length.
- policy
Name string - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- user
Type string - The type of the tag policy. Valid values:
USER
,RD
.
- policy_
content str - The content of the policy.
- policy_
desc str - The description of the policy. The description must be 1 to 512 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 (-).
- user_
type str - The type of the tag policy. Valid values:
USER
,RD
.
- policy
Content String - The content of the policy.
- policy
Desc String - The description of the policy. The description must be 1 to 512 characters in length.
- policy
Name String - The name of the policy. name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).
- user
Type String - The type of the tag policy. Valid values:
USER
,RD
.
Import
Tag Policy can be imported using the id, e.g.
$ pulumi import alicloud:tag/policy:Policy example <id>
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.