1. Packages
  2. Consul Provider
  3. API Docs
  4. AclPolicy
Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi

consul.AclPolicy

Explore with Pulumi AI

consul logo
Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi

    Starting with Consul 1.4.0, the consul.AclPolicy can be used to managed Consul ACL policies.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as consul from "@pulumi/consul";
    
    const test = new consul.AclPolicy("test", {
        name: "my_policy",
        datacenters: ["dc1"],
        rules: `node_prefix "" {
      policy = "read"
    }
    `,
    });
    
    import pulumi
    import pulumi_consul as consul
    
    test = consul.AclPolicy("test",
        name="my_policy",
        datacenters=["dc1"],
        rules="""node_prefix "" {
      policy = "read"
    }
    """)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := consul.NewAclPolicy(ctx, "test", &consul.AclPolicyArgs{
    			Name: pulumi.String("my_policy"),
    			Datacenters: pulumi.StringArray{
    				pulumi.String("dc1"),
    			},
    			Rules: pulumi.String("node_prefix \"\" {\n  policy = \"read\"\n}\n"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Consul = Pulumi.Consul;
    
    return await Deployment.RunAsync(() => 
    {
        var test = new Consul.AclPolicy("test", new()
        {
            Name = "my_policy",
            Datacenters = new[]
            {
                "dc1",
            },
            Rules = @"node_prefix """" {
      policy = ""read""
    }
    ",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.consul.AclPolicy;
    import com.pulumi.consul.AclPolicyArgs;
    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 test = new AclPolicy("test", AclPolicyArgs.builder()
                .name("my_policy")
                .datacenters("dc1")
                .rules("""
    node_prefix "" {
      policy = "read"
    }
                """)
                .build());
    
        }
    }
    
    resources:
      test:
        type: consul:AclPolicy
        properties:
          name: my_policy
          datacenters:
            - dc1
          rules: |
            node_prefix "" {
              policy = "read"
            }        
    

    Create AclPolicy Resource

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

    Constructor syntax

    new AclPolicy(name: string, args: AclPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def AclPolicy(resource_name: str,
                  args: AclPolicyArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def AclPolicy(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  rules: Optional[str] = None,
                  datacenters: Optional[Sequence[str]] = None,
                  description: Optional[str] = None,
                  name: Optional[str] = None,
                  namespace: Optional[str] = None,
                  partition: Optional[str] = None)
    func NewAclPolicy(ctx *Context, name string, args AclPolicyArgs, opts ...ResourceOption) (*AclPolicy, error)
    public AclPolicy(string name, AclPolicyArgs args, CustomResourceOptions? opts = null)
    public AclPolicy(String name, AclPolicyArgs args)
    public AclPolicy(String name, AclPolicyArgs args, CustomResourceOptions options)
    
    type: consul:AclPolicy
    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 AclPolicyArgs
    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 AclPolicyArgs
    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 AclPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AclPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AclPolicyArgs
    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 aclPolicyResource = new Consul.AclPolicy("aclPolicyResource", new()
    {
        Rules = "string",
        Datacenters = new[]
        {
            "string",
        },
        Description = "string",
        Name = "string",
        Namespace = "string",
        Partition = "string",
    });
    
    example, err := consul.NewAclPolicy(ctx, "aclPolicyResource", &consul.AclPolicyArgs{
    	Rules: pulumi.String("string"),
    	Datacenters: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Description: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    	Namespace:   pulumi.String("string"),
    	Partition:   pulumi.String("string"),
    })
    
    var aclPolicyResource = new AclPolicy("aclPolicyResource", AclPolicyArgs.builder()
        .rules("string")
        .datacenters("string")
        .description("string")
        .name("string")
        .namespace("string")
        .partition("string")
        .build());
    
    acl_policy_resource = consul.AclPolicy("aclPolicyResource",
        rules="string",
        datacenters=["string"],
        description="string",
        name="string",
        namespace="string",
        partition="string")
    
    const aclPolicyResource = new consul.AclPolicy("aclPolicyResource", {
        rules: "string",
        datacenters: ["string"],
        description: "string",
        name: "string",
        namespace: "string",
        partition: "string",
    });
    
    type: consul:AclPolicy
    properties:
        datacenters:
            - string
        description: string
        name: string
        namespace: string
        partition: string
        rules: string
    

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

    Rules string
    The rules of the policy.
    Datacenters List<string>
    The datacenters of the policy.
    Description string
    The description of the policy.
    Name string
    The name of the policy.
    Namespace string
    The namespace to create the policy within.
    Partition string
    The partition the ACL policy is associated with.
    Rules string
    The rules of the policy.
    Datacenters []string
    The datacenters of the policy.
    Description string
    The description of the policy.
    Name string
    The name of the policy.
    Namespace string
    The namespace to create the policy within.
    Partition string
    The partition the ACL policy is associated with.
    rules String
    The rules of the policy.
    datacenters List<String>
    The datacenters of the policy.
    description String
    The description of the policy.
    name String
    The name of the policy.
    namespace String
    The namespace to create the policy within.
    partition String
    The partition the ACL policy is associated with.
    rules string
    The rules of the policy.
    datacenters string[]
    The datacenters of the policy.
    description string
    The description of the policy.
    name string
    The name of the policy.
    namespace string
    The namespace to create the policy within.
    partition string
    The partition the ACL policy is associated with.
    rules str
    The rules of the policy.
    datacenters Sequence[str]
    The datacenters of the policy.
    description str
    The description of the policy.
    name str
    The name of the policy.
    namespace str
    The namespace to create the policy within.
    partition str
    The partition the ACL policy is associated with.
    rules String
    The rules of the policy.
    datacenters List<String>
    The datacenters of the policy.
    description String
    The description of the policy.
    name String
    The name of the policy.
    namespace String
    The namespace to create the policy within.
    partition String
    The partition the ACL policy is associated with.

    Outputs

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

    Get an existing AclPolicy 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?: AclPolicyState, opts?: CustomResourceOptions): AclPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datacenters: Optional[Sequence[str]] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            namespace: Optional[str] = None,
            partition: Optional[str] = None,
            rules: Optional[str] = None) -> AclPolicy
    func GetAclPolicy(ctx *Context, name string, id IDInput, state *AclPolicyState, opts ...ResourceOption) (*AclPolicy, error)
    public static AclPolicy Get(string name, Input<string> id, AclPolicyState? state, CustomResourceOptions? opts = null)
    public static AclPolicy get(String name, Output<String> id, AclPolicyState 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:
    Datacenters List<string>
    The datacenters of the policy.
    Description string
    The description of the policy.
    Name string
    The name of the policy.
    Namespace string
    The namespace to create the policy within.
    Partition string
    The partition the ACL policy is associated with.
    Rules string
    The rules of the policy.
    Datacenters []string
    The datacenters of the policy.
    Description string
    The description of the policy.
    Name string
    The name of the policy.
    Namespace string
    The namespace to create the policy within.
    Partition string
    The partition the ACL policy is associated with.
    Rules string
    The rules of the policy.
    datacenters List<String>
    The datacenters of the policy.
    description String
    The description of the policy.
    name String
    The name of the policy.
    namespace String
    The namespace to create the policy within.
    partition String
    The partition the ACL policy is associated with.
    rules String
    The rules of the policy.
    datacenters string[]
    The datacenters of the policy.
    description string
    The description of the policy.
    name string
    The name of the policy.
    namespace string
    The namespace to create the policy within.
    partition string
    The partition the ACL policy is associated with.
    rules string
    The rules of the policy.
    datacenters Sequence[str]
    The datacenters of the policy.
    description str
    The description of the policy.
    name str
    The name of the policy.
    namespace str
    The namespace to create the policy within.
    partition str
    The partition the ACL policy is associated with.
    rules str
    The rules of the policy.
    datacenters List<String>
    The datacenters of the policy.
    description String
    The description of the policy.
    name String
    The name of the policy.
    namespace String
    The namespace to create the policy within.
    partition String
    The partition the ACL policy is associated with.
    rules String
    The rules of the policy.

    Import

    consul_acl_policy can be imported:

    $ pulumi import consul:index/aclPolicy:AclPolicy my-policy 1c90ef03-a6dd-6a8c-ac49-042ad3752896
    

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

    Package Details

    Repository
    HashiCorp Consul pulumi/pulumi-consul
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the consul Terraform Provider.
    consul logo
    Consul v3.12.1 published on Friday, Aug 23, 2024 by Pulumi