1. Packages
  2. Ucloud Provider
  3. API Docs
  4. IamPolicy
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.IamPolicy

Explore with Pulumi AI

ucloud logo
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

    Provides an IAM custom policy resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const foo = new ucloud.IamPolicy("foo", {
        comment: "comment",
        policy: JSON.stringify({
            Version: "1",
            Statement: [{
                Action: ["*"],
                Effect: "Allow",
                Resource: ["*"],
            }],
        }),
        scope: "Project",
    });
    
    import pulumi
    import json
    import pulumi_ucloud as ucloud
    
    foo = ucloud.IamPolicy("foo",
        comment="comment",
        policy=json.dumps({
            "Version": "1",
            "Statement": [{
                "Action": ["*"],
                "Effect": "Allow",
                "Resource": ["*"],
            }],
        }),
        scope="Project")
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Version": "1",
    			"Statement": []map[string]interface{}{
    				map[string]interface{}{
    					"Action": []string{
    						"*",
    					},
    					"Effect": "Allow",
    					"Resource": []string{
    						"*",
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = ucloud.NewIamPolicy(ctx, "foo", &ucloud.IamPolicyArgs{
    			Comment: pulumi.String("comment"),
    			Policy:  pulumi.String(json0),
    			Scope:   pulumi.String("Project"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = new Ucloud.IamPolicy("foo", new()
        {
            Comment = "comment",
            Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "1",
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Action"] = new[]
                        {
                            "*",
                        },
                        ["Effect"] = "Allow",
                        ["Resource"] = new[]
                        {
                            "*",
                        },
                    },
                },
            }),
            Scope = "Project",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.IamPolicy;
    import com.pulumi.ucloud.IamPolicyArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 foo = new IamPolicy("foo", IamPolicyArgs.builder()
                .comment("comment")
                .policy(serializeJson(
                    jsonObject(
                        jsonProperty("Version", "1"),
                        jsonProperty("Statement", jsonArray(jsonObject(
                            jsonProperty("Action", jsonArray("*")),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Resource", jsonArray("*"))
                        )))
                    )))
                .scope("Project")
                .build());
    
        }
    }
    
    resources:
      foo:
        type: ucloud:IamPolicy
        properties:
          comment: comment
          policy:
            fn::toJSON:
              Version: '1'
              Statement:
                - Action:
                    - '*'
                  Effect: Allow
                  Resource:
                    - '*'
          scope: Project
    

    Create IamPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new IamPolicy(name: string, args: IamPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def IamPolicy(resource_name: str,
                  args: IamPolicyArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def IamPolicy(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  policy: Optional[str] = None,
                  scope: Optional[str] = None,
                  comment: Optional[str] = None,
                  iam_policy_id: Optional[str] = None,
                  name: Optional[str] = None)
    func NewIamPolicy(ctx *Context, name string, args IamPolicyArgs, opts ...ResourceOption) (*IamPolicy, error)
    public IamPolicy(string name, IamPolicyArgs args, CustomResourceOptions? opts = null)
    public IamPolicy(String name, IamPolicyArgs args)
    public IamPolicy(String name, IamPolicyArgs args, CustomResourceOptions options)
    
    type: ucloud:IamPolicy
    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 IamPolicyArgs
    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 IamPolicyArgs
    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 IamPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args IamPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args IamPolicyArgs
    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 iamPolicyResource = new Ucloud.IamPolicy("iamPolicyResource", new()
    {
        Policy = "string",
        Scope = "string",
        Comment = "string",
        IamPolicyId = "string",
        Name = "string",
    });
    
    example, err := ucloud.NewIamPolicy(ctx, "iamPolicyResource", &ucloud.IamPolicyArgs{
    	Policy:      pulumi.String("string"),
    	Scope:       pulumi.String("string"),
    	Comment:     pulumi.String("string"),
    	IamPolicyId: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    })
    
    var iamPolicyResource = new IamPolicy("iamPolicyResource", IamPolicyArgs.builder()
        .policy("string")
        .scope("string")
        .comment("string")
        .iamPolicyId("string")
        .name("string")
        .build());
    
    iam_policy_resource = ucloud.IamPolicy("iamPolicyResource",
        policy="string",
        scope="string",
        comment="string",
        iam_policy_id="string",
        name="string")
    
    const iamPolicyResource = new ucloud.IamPolicy("iamPolicyResource", {
        policy: "string",
        scope: "string",
        comment: "string",
        iamPolicyId: "string",
        name: "string",
    });
    
    type: ucloud:IamPolicy
    properties:
        comment: string
        iamPolicyId: string
        name: string
        policy: string
        scope: string
    

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

    Policy string
    The policy document. This is a JSON formatted string.
    Scope string
    The policy scope, which value can be Project or Account.
    Comment string
    Comments of the IAM policy.
    IamPolicyId string
    Name string
    The name of the policy.
    Policy string
    The policy document. This is a JSON formatted string.
    Scope string
    The policy scope, which value can be Project or Account.
    Comment string
    Comments of the IAM policy.
    IamPolicyId string
    Name string
    The name of the policy.
    policy String
    The policy document. This is a JSON formatted string.
    scope String
    The policy scope, which value can be Project or Account.
    comment String
    Comments of the IAM policy.
    iamPolicyId String
    name String
    The name of the policy.
    policy string
    The policy document. This is a JSON formatted string.
    scope string
    The policy scope, which value can be Project or Account.
    comment string
    Comments of the IAM policy.
    iamPolicyId string
    name string
    The name of the policy.
    policy str
    The policy document. This is a JSON formatted string.
    scope str
    The policy scope, which value can be Project or Account.
    comment str
    Comments of the IAM policy.
    iam_policy_id str
    name str
    The name of the policy.
    policy String
    The policy document. This is a JSON formatted string.
    scope String
    The policy scope, which value can be Project or Account.
    comment String
    Comments of the IAM policy.
    iamPolicyId String
    name String
    The name of the policy.

    Outputs

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

    CreateTime string
    The time of creation of policy, formatted in RFC3339 time string.
    Id string
    The provider-assigned unique ID for this managed resource.
    UcloudUrn string
    URN of the policy.
    CreateTime string
    The time of creation of policy, formatted in RFC3339 time string.
    Id string
    The provider-assigned unique ID for this managed resource.
    UcloudUrn string
    URN of the policy.
    createTime String
    The time of creation of policy, formatted in RFC3339 time string.
    id String
    The provider-assigned unique ID for this managed resource.
    ucloudUrn String
    URN of the policy.
    createTime string
    The time of creation of policy, formatted in RFC3339 time string.
    id string
    The provider-assigned unique ID for this managed resource.
    ucloudUrn string
    URN of the policy.
    create_time str
    The time of creation of policy, formatted in RFC3339 time string.
    id str
    The provider-assigned unique ID for this managed resource.
    ucloud_urn str
    URN of the policy.
    createTime String
    The time of creation of policy, formatted in RFC3339 time string.
    id String
    The provider-assigned unique ID for this managed resource.
    ucloudUrn String
    URN of the policy.

    Look up Existing IamPolicy Resource

    Get an existing IamPolicy 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?: IamPolicyState, opts?: CustomResourceOptions): IamPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            comment: Optional[str] = None,
            create_time: Optional[str] = None,
            iam_policy_id: Optional[str] = None,
            name: Optional[str] = None,
            policy: Optional[str] = None,
            scope: Optional[str] = None,
            ucloud_urn: Optional[str] = None) -> IamPolicy
    func GetIamPolicy(ctx *Context, name string, id IDInput, state *IamPolicyState, opts ...ResourceOption) (*IamPolicy, error)
    public static IamPolicy Get(string name, Input<string> id, IamPolicyState? state, CustomResourceOptions? opts = null)
    public static IamPolicy get(String name, Output<String> id, IamPolicyState state, CustomResourceOptions options)
    resources:  _:    type: ucloud:IamPolicy    get:      id: ${id}
    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:
    Comment string
    Comments of the IAM policy.
    CreateTime string
    The time of creation of policy, formatted in RFC3339 time string.
    IamPolicyId string
    Name string
    The name of the policy.
    Policy string
    The policy document. This is a JSON formatted string.
    Scope string
    The policy scope, which value can be Project or Account.
    UcloudUrn string
    URN of the policy.
    Comment string
    Comments of the IAM policy.
    CreateTime string
    The time of creation of policy, formatted in RFC3339 time string.
    IamPolicyId string
    Name string
    The name of the policy.
    Policy string
    The policy document. This is a JSON formatted string.
    Scope string
    The policy scope, which value can be Project or Account.
    UcloudUrn string
    URN of the policy.
    comment String
    Comments of the IAM policy.
    createTime String
    The time of creation of policy, formatted in RFC3339 time string.
    iamPolicyId String
    name String
    The name of the policy.
    policy String
    The policy document. This is a JSON formatted string.
    scope String
    The policy scope, which value can be Project or Account.
    ucloudUrn String
    URN of the policy.
    comment string
    Comments of the IAM policy.
    createTime string
    The time of creation of policy, formatted in RFC3339 time string.
    iamPolicyId string
    name string
    The name of the policy.
    policy string
    The policy document. This is a JSON formatted string.
    scope string
    The policy scope, which value can be Project or Account.
    ucloudUrn string
    URN of the policy.
    comment str
    Comments of the IAM policy.
    create_time str
    The time of creation of policy, formatted in RFC3339 time string.
    iam_policy_id str
    name str
    The name of the policy.
    policy str
    The policy document. This is a JSON formatted string.
    scope str
    The policy scope, which value can be Project or Account.
    ucloud_urn str
    URN of the policy.
    comment String
    Comments of the IAM policy.
    createTime String
    The time of creation of policy, formatted in RFC3339 time string.
    iamPolicyId String
    name String
    The name of the policy.
    policy String
    The policy document. This is a JSON formatted string.
    scope String
    The policy scope, which value can be Project or Account.
    ucloudUrn String
    URN of the policy.

    Import

    IAM group can be imported using policy name, e.g.

    $ pulumi import ucloud:index/iamPolicy:IamPolicy example uhost-policy
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud logo
    ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud