consul.AclToken
Explore with Pulumi AI
The consul.AclToken
resource writes an ACL token into Consul.
Example Usage
Basic usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;
return await Deployment.RunAsync(() =>
{
var agent = new Consul.AclPolicy("agent", new()
{
Rules = @"node_prefix """" {
policy = ""read""
}
",
});
var test = new Consul.AclToken("test", new()
{
Description = "my test token",
Local = true,
Policies = new[]
{
agent.Name,
},
});
});
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 {
agent, err := consul.NewAclPolicy(ctx, "agent", &consul.AclPolicyArgs{
Rules: pulumi.String("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
})
}
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 com.pulumi.consul.AclToken;
import com.pulumi.consul.AclTokenArgs;
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 agent = new AclPolicy("agent", AclPolicyArgs.builder()
.rules("""
node_prefix "" {
policy = "read"
}
""")
.build());
var test = new AclToken("test", AclTokenArgs.builder()
.description("my test token")
.local(true)
.policies(agent.name())
.build());
}
}
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],
});
resources:
agent:
type: consul:AclPolicy
properties:
rules: |+
node_prefix "" {
policy = "read"
}
test:
type: consul:AclToken
properties:
description: my test token
local: true
policies:
- ${agent.name}
Create AclToken Resource
new AclToken(name: string, args?: AclTokenArgs, opts?: CustomResourceOptions);
@overload
def AclToken(resource_name: str,
opts: Optional[ResourceOptions] = None,
accessor_id: Optional[str] = None,
description: Optional[str] = None,
expiration_time: Optional[str] = None,
local: Optional[bool] = None,
namespace: Optional[str] = None,
node_identities: Optional[Sequence[AclTokenNodeIdentityArgs]] = None,
partition: Optional[str] = None,
policies: Optional[Sequence[str]] = None,
roles: Optional[Sequence[str]] = None,
service_identities: Optional[Sequence[AclTokenServiceIdentityArgs]] = None)
@overload
def AclToken(resource_name: str,
args: Optional[AclTokenArgs] = None,
opts: Optional[ResourceOptions] = None)
func NewAclToken(ctx *Context, name string, args *AclTokenArgs, opts ...ResourceOption) (*AclToken, error)
public AclToken(string name, AclTokenArgs? args = null, CustomResourceOptions? opts = null)
public AclToken(String name, AclTokenArgs args)
public AclToken(String name, AclTokenArgs args, CustomResourceOptions options)
type: consul:AclToken
properties: # The arguments to resource properties.
options: # 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.
- resource_name str
- The unique name of the resource.
- args AclTokenArgs
- 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 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.
- name String
- The unique name of the resource.
- args AclTokenArgs
- The arguments to resource properties.
- options 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 Architecture and Concepts docs.
Inputs
The AclToken resource accepts the following input properties:
- Accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- Description string
The description of the token.
- Expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- Local bool
The flag to set the token local to the current datacenter.
- Namespace string
The namespace to create the token within.
- Node
Identities List<AclToken Node Identity> The list of node identities that should be applied to the token.
- Partition string
The partition the ACL token is associated with.
- Policies List<string>
The list of policies attached to the token.
- Roles List<string>
The list of roles attached to the token.
- Service
Identities List<AclToken Service Identity> The list of service identities that should be applied to the token.
- Accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- Description string
The description of the token.
- Expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- Local bool
The flag to set the token local to the current datacenter.
- Namespace string
The namespace to create the token within.
- Node
Identities []AclToken Node Identity Args The list of node identities that should be applied to the token.
- Partition string
The partition the ACL token is associated with.
- Policies []string
The list of policies attached to the token.
- Roles []string
The list of roles attached to the token.
- Service
Identities []AclToken Service Identity Args The list of service identities that should be applied to the token.
- accessor
Id String The uuid of the token. If omitted, Consul will generate a random uuid.
- description String
The description of the token.
- expiration
Time String If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local Boolean
The flag to set the token local to the current datacenter.
- namespace String
The namespace to create the token within.
- node
Identities List<AclToken Node Identity> The list of node identities that should be applied to the token.
- partition String
The partition the ACL token is associated with.
- policies List<String>
The list of policies attached to the token.
- roles List<String>
The list of roles attached to the token.
- service
Identities List<AclToken Service Identity> The list of service identities that should be applied to the token.
- accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- description string
The description of the token.
- expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local boolean
The flag to set the token local to the current datacenter.
- namespace string
The namespace to create the token within.
- node
Identities AclToken Node Identity[] The list of node identities that should be applied to the token.
- partition string
The partition the ACL token is associated with.
- policies string[]
The list of policies attached to the token.
- roles string[]
The list of roles attached to the token.
- service
Identities AclToken Service Identity[] The list of service identities that should be applied 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.
- expiration_
time str If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local bool
The flag to set the token local to the current datacenter.
- namespace str
The namespace to create the token within.
- node_
identities Sequence[AclToken Node Identity Args] The list of node identities that should be applied to the token.
- partition str
The partition the ACL token is associated with.
- policies Sequence[str]
The list of policies attached to the token.
- roles Sequence[str]
The list of roles attached to the token.
- service_
identities Sequence[AclToken Service Identity Args] The list of service identities that should be applied to the token.
- accessor
Id String The uuid of the token. If omitted, Consul will generate a random uuid.
- description String
The description of the token.
- expiration
Time String If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local Boolean
The flag to set the token local to the current datacenter.
- namespace String
The namespace to create the token within.
- node
Identities List<Property Map> The list of node identities that should be applied to the token.
- partition String
The partition the ACL token is associated with.
- policies List<String>
The list of policies attached to the token.
- roles List<String>
The list of roles attached to the token.
- service
Identities List<Property Map> The list of service identities that should be applied 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 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 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,
expiration_time: Optional[str] = None,
local: Optional[bool] = None,
namespace: Optional[str] = None,
node_identities: Optional[Sequence[AclTokenNodeIdentityArgs]] = None,
partition: Optional[str] = None,
policies: Optional[Sequence[str]] = None,
roles: Optional[Sequence[str]] = None,
service_identities: Optional[Sequence[AclTokenServiceIdentityArgs]] = 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)
public static AclToken get(String name, Output<String> id, AclTokenState 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.
- Accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- Description string
The description of the token.
- Expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- Local bool
The flag to set the token local to the current datacenter.
- Namespace string
The namespace to create the token within.
- Node
Identities List<AclToken Node Identity> The list of node identities that should be applied to the token.
- Partition string
The partition the ACL token is associated with.
- Policies List<string>
The list of policies attached to the token.
- Roles List<string>
The list of roles attached to the token.
- Service
Identities List<AclToken Service Identity> The list of service identities that should be applied to the token.
- Accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- Description string
The description of the token.
- Expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- Local bool
The flag to set the token local to the current datacenter.
- Namespace string
The namespace to create the token within.
- Node
Identities []AclToken Node Identity Args The list of node identities that should be applied to the token.
- Partition string
The partition the ACL token is associated with.
- Policies []string
The list of policies attached to the token.
- Roles []string
The list of roles attached to the token.
- Service
Identities []AclToken Service Identity Args The list of service identities that should be applied to the token.
- accessor
Id String The uuid of the token. If omitted, Consul will generate a random uuid.
- description String
The description of the token.
- expiration
Time String If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local Boolean
The flag to set the token local to the current datacenter.
- namespace String
The namespace to create the token within.
- node
Identities List<AclToken Node Identity> The list of node identities that should be applied to the token.
- partition String
The partition the ACL token is associated with.
- policies List<String>
The list of policies attached to the token.
- roles List<String>
The list of roles attached to the token.
- service
Identities List<AclToken Service Identity> The list of service identities that should be applied to the token.
- accessor
Id string The uuid of the token. If omitted, Consul will generate a random uuid.
- description string
The description of the token.
- expiration
Time string If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local boolean
The flag to set the token local to the current datacenter.
- namespace string
The namespace to create the token within.
- node
Identities AclToken Node Identity[] The list of node identities that should be applied to the token.
- partition string
The partition the ACL token is associated with.
- policies string[]
The list of policies attached to the token.
- roles string[]
The list of roles attached to the token.
- service
Identities AclToken Service Identity[] The list of service identities that should be applied 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.
- expiration_
time str If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local bool
The flag to set the token local to the current datacenter.
- namespace str
The namespace to create the token within.
- node_
identities Sequence[AclToken Node Identity Args] The list of node identities that should be applied to the token.
- partition str
The partition the ACL token is associated with.
- policies Sequence[str]
The list of policies attached to the token.
- roles Sequence[str]
The list of roles attached to the token.
- service_
identities Sequence[AclToken Service Identity Args] The list of service identities that should be applied to the token.
- accessor
Id String The uuid of the token. If omitted, Consul will generate a random uuid.
- description String
The description of the token.
- expiration
Time String If set this represents the point after which a token should be considered revoked and is eligible for destruction.
- local Boolean
The flag to set the token local to the current datacenter.
- namespace String
The namespace to create the token within.
- node
Identities List<Property Map> The list of node identities that should be applied to the token.
- partition String
The partition the ACL token is associated with.
- policies List<String>
The list of policies attached to the token.
- roles List<String>
The list of roles attached to the token.
- service
Identities List<Property Map> The list of service identities that should be applied to the token.
Supporting Types
AclTokenNodeIdentity, AclTokenNodeIdentityArgs
- Datacenter string
The datacenter of the node.
- Node
Name string The name of the node.
- Datacenter string
The datacenter of the node.
- Node
Name string The name of the node.
- datacenter String
The datacenter of the node.
- node
Name String The name of the node.
- datacenter string
The datacenter of the node.
- node
Name string The name of the node.
- datacenter str
The datacenter of the node.
- node_
name str The name of the node.
- datacenter String
The datacenter of the node.
- node
Name String The name of the node.
AclTokenServiceIdentity, AclTokenServiceIdentityArgs
- Service
Name string The name of the service.
- Datacenters List<string>
The list of datacenters the policy is valid within.
- Service
Name string The name of the service.
- Datacenters []string
The list of datacenters the policy is valid within.
- service
Name String The name of the service.
- datacenters List<String>
The list of datacenters the policy is valid within.
- service
Name string The name of the service.
- datacenters string[]
The list of datacenters the policy is valid within.
- service_
name str The name of the service.
- datacenters Sequence[str]
The list of datacenters the policy is valid within.
- service
Name String The name of the service.
- datacenters List<String>
The list of datacenters the policy is valid within.
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
- HashiCorp Consul pulumi/pulumi-consul
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
consul
Terraform Provider.