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

AclToken

The consul.AclToken resource writes an ACL token into Consul.

Example Usage

Basic usage

using Pulumi;
using Consul = Pulumi.Consul;

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

",
        });
        var test = new Consul.AclToken("test", new Consul.AclTokenArgs
        {
            Description = "my test token",
            Local = true,
            Policies = 
            {
                agent.Name,
            },
        });
    }

}
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 {
        agent, err := consul.NewAclPolicy(ctx, "agent", &consul.AclPolicyArgs{
            Rules: pulumi.String(fmt.Sprintf("%v%v%v%v", "node_prefix \"\" {\n", "  policy = \"read\"\n", "}\n", "\n")),
        })
        if err != nil {
            return err
        }
        _, err = consul.NewAclToken(ctx, "test", &consul.AclTokenArgs{
            Description: pulumi.String("my test token"),
            Local:       pulumi.Bool(true),
            Policies: pulumi.StringArray{
                agent.Name,
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_consul as consul

agent = consul.AclPolicy("agent", rules="""node_prefix "" {
  policy = "read"
}

""")
test = consul.AclToken("test",
    description="my test token",
    local=True,
    policies=[agent.name])
import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const agent = new consul.AclPolicy("agent", {
    rules: `node_prefix "" {
  policy = "read"
}
`,
});
const test = new consul.AclToken("test", {
    description: "my test token",
    local: true,
    policies: [agent.name],
});

Create a AclToken Resource

new AclToken(name: string, args?: AclTokenArgs, opts?: CustomResourceOptions);
def AclToken(resource_name: str, opts: Optional[ResourceOptions] = None, accessor_id: Optional[str] = None, description: Optional[str] = None, local: Optional[bool] = None, namespace: Optional[str] = None, policies: Optional[Sequence[str]] = None, roles: Optional[Sequence[str]] = None)
func NewAclToken(ctx *Context, name string, args *AclTokenArgs, opts ...ResourceOption) (*AclToken, error)
public AclToken(string name, AclTokenArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args AclTokenArgs
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 AclTokenArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AclTokenArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

AclToken Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The AclToken resource accepts the following input properties:

AccessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

Description string

The description of the token.

Local bool

The flag to set the token local to the current datacenter.

Namespace string

The namespace to create the token within.

Policies List<string>

The list of policies attached to the token.

Roles List<string>

The list of roles attached to the token.

AccessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

Description string

The description of the token.

Local bool

The flag to set the token local to the current datacenter.

Namespace string

The namespace to create the token within.

Policies []string

The list of policies attached to the token.

Roles []string

The list of roles attached to the token.

accessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

description string

The description of the token.

local boolean

The flag to set the token local to the current datacenter.

namespace string

The namespace to create the token within.

policies string[]

The list of policies attached to the token.

roles string[]

The list of roles attached to the token.

accessor_id str

The uuid of the token. If omitted, Consul will generate a random uuid.

description str

The description of the token.

local bool

The flag to set the token local to the current datacenter.

namespace str

The namespace to create the token within.

policies Sequence[str]

The list of policies attached to the token.

roles Sequence[str]

The list of roles attached to the token.

Outputs

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

Get an existing AclToken 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?: AclTokenState, opts?: CustomResourceOptions): AclToken
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, accessor_id: Optional[str] = None, description: Optional[str] = None, local: Optional[bool] = None, namespace: Optional[str] = None, policies: Optional[Sequence[str]] = None, roles: Optional[Sequence[str]] = None) -> AclToken
func GetAclToken(ctx *Context, name string, id IDInput, state *AclTokenState, opts ...ResourceOption) (*AclToken, error)
public static AclToken Get(string name, Input<string> id, AclTokenState? 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:

AccessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

Description string

The description of the token.

Local bool

The flag to set the token local to the current datacenter.

Namespace string

The namespace to create the token within.

Policies List<string>

The list of policies attached to the token.

Roles List<string>

The list of roles attached to the token.

AccessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

Description string

The description of the token.

Local bool

The flag to set the token local to the current datacenter.

Namespace string

The namespace to create the token within.

Policies []string

The list of policies attached to the token.

Roles []string

The list of roles attached to the token.

accessorId string

The uuid of the token. If omitted, Consul will generate a random uuid.

description string

The description of the token.

local boolean

The flag to set the token local to the current datacenter.

namespace string

The namespace to create the token within.

policies string[]

The list of policies attached to the token.

roles string[]

The list of roles attached to the token.

accessor_id str

The uuid of the token. If omitted, Consul will generate a random uuid.

description str

The description of the token.

local bool

The flag to set the token local to the current datacenter.

namespace str

The namespace to create the token within.

policies Sequence[str]

The list of policies attached to the token.

roles Sequence[str]

The list of roles attached to the token.

Import

consul_acl_token can be imported. This is especially useful to manage the anonymous and the master token with Terraform

 $ pulumi import consul:index/aclToken:AclToken anonymous 00000000-0000-0000-0000-000000000002
 $ pulumi import consul:index/aclToken:AclToken master-token 624d94ca-bc5c-f960-4e83-0a609cf588be

Package Details

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