1. Packages
  2. Consul Provider
  3. API Docs
  4. AclPolicy
Consul v3.12.4 published on Wednesday, Feb 12, 2025 by Pulumi

consul.AclPolicy

Explore with Pulumi AI

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"
}
`,
});
Copy
import pulumi
import pulumi_consul as consul

test = consul.AclPolicy("test",
    name="my_policy",
    datacenters=["dc1"],
    rules="""node_prefix "" {
  policy = "read"
}
""")
Copy
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
	})
}
Copy
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""
}
",
    });

});
Copy
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());

    }
}
Copy
resources:
  test:
    type: consul:AclPolicy
    properties:
      name: my_policy
      datacenters:
        - dc1
      rules: |
        node_prefix "" {
          policy = "read"
        }        
Copy

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 This property is required. string
The unique name of the resource.
args This property is required. AclPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. AclPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. AclPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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",
});
Copy
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"),
})
Copy
var aclPolicyResource = new AclPolicy("aclPolicyResource", AclPolicyArgs.builder()
    .rules("string")
    .datacenters("string")
    .description("string")
    .name("string")
    .namespace("string")
    .partition("string")
    .build());
Copy
acl_policy_resource = consul.AclPolicy("aclPolicyResource",
    rules="string",
    datacenters=["string"],
    description="string",
    name="string",
    namespace="string",
    partition="string")
Copy
const aclPolicyResource = new consul.AclPolicy("aclPolicyResource", {
    rules: "string",
    datacenters: ["string"],
    description: "string",
    name: "string",
    namespace: "string",
    partition: "string",
});
Copy
type: consul:AclPolicy
properties:
    datacenters:
        - string
    description: string
    name: string
    namespace: string
    partition: string
    rules: string
Copy

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

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The AclPolicy resource accepts the following input properties:

Rules This property is required. 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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
Partition Changes to this property will trigger replacement. string
The partition the ACL policy is associated with.
Rules This property is required. 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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
Partition Changes to this property will trigger replacement. string
The partition the ACL policy is associated with.
rules This property is required. 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 Changes to this property will trigger replacement. String
The namespace to create the policy within.
partition Changes to this property will trigger replacement. String
The partition the ACL policy is associated with.
rules This property is required. 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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
partition Changes to this property will trigger replacement. string
The partition the ACL policy is associated with.
rules This property is required. 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 Changes to this property will trigger replacement. str
The namespace to create the policy within.
partition Changes to this property will trigger replacement. str
The partition the ACL policy is associated with.
rules This property is required. 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 Changes to this property will trigger replacement. String
The namespace to create the policy within.
partition Changes to this property will trigger replacement. 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)
resources:  _:    type: consul:AclPolicy    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
Partition Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
Partition Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. String
The namespace to create the policy within.
partition Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. string
The namespace to create the policy within.
partition Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. str
The namespace to create the policy within.
partition Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. String
The namespace to create the policy within.
partition Changes to this property will trigger replacement. 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
Copy

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.