Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

AclPolicy

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

Example Usage

using Pulumi;
using Consul = Pulumi.Consul;

class MyStack : Stack
{
    public MyStack()
    {
        var test = new Consul.AclPolicy("test", new Consul.AclPolicyArgs
        {
            Datacenters = 
            {
                "dc1",
            },
            Rules = @"node_prefix """" {
  policy = ""read""
}

",
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-consul/sdk/v2/go/consul"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := consul.NewAclPolicy(ctx, "test", &consul.AclPolicyArgs{
            Datacenters: pulumi.StringArray{
                pulumi.String("dc1"),
            },
            Rules: pulumi.String(fmt.Sprintf("%v%v%v%v", "node_prefix \"\" {\n", "  policy = \"read\"\n", "}\n", "\n")),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_consul as consul

test = consul.AclPolicy("test",
    datacenters=["dc1"],
    rules="""node_prefix "" {
  policy = "read"
}

""")
import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const test = new consul.AclPolicy("test", {
    datacenters: ["dc1"],
    rules: `node_prefix "" {
  policy = "read"
}
`,
});

Create a AclPolicy Resource

new AclPolicy(name: string, args: AclPolicyArgs, opts?: CustomResourceOptions);
def AclPolicy(resource_name: str, opts: Optional[ResourceOptions] = None, datacenters: Optional[Sequence[str]] = None, description: Optional[str] = None, name: Optional[str] = None, namespace: Optional[str] = None, rules: Optional[str] = None)
func NewAclPolicy(ctx *Context, name string, args AclPolicyArgs, opts ...ResourceOption) (*AclPolicy, error)
public AclPolicy(string name, AclPolicyArgs args, CustomResourceOptions? opts = null)
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.
opts ResourceOptions
A bag of options that control this 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.

AclPolicy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model 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.

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.

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.

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.

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 str
The provider-assigned unique ID for this managed resource.

Look up an 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, 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)
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.

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.

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.

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.

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.

rules str

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

Package Details

Repository
https://github.com/pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.