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

consul.AclRole

Explore with Pulumi AI

Example Usage

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

const read_policy = new consul.AclPolicy("read-policy", {
    name: "read-policy",
    rules: "node \"\" { policy = \"read\" }",
    datacenters: ["dc1"],
});
const read = new consul.AclRole("read", {
    name: "foo",
    description: "bar",
    policies: [read_policy.id],
    serviceIdentities: [{
        serviceName: "foo",
    }],
});
Copy
import pulumi
import pulumi_consul as consul

read_policy = consul.AclPolicy("read-policy",
    name="read-policy",
    rules="node \"\" { policy = \"read\" }",
    datacenters=["dc1"])
read = consul.AclRole("read",
    name="foo",
    description="bar",
    policies=[read_policy.id],
    service_identities=[{
        "service_name": "foo",
    }])
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 {
		read_policy, err := consul.NewAclPolicy(ctx, "read-policy", &consul.AclPolicyArgs{
			Name:  pulumi.String("read-policy"),
			Rules: pulumi.String("node \"\" { policy = \"read\" }"),
			Datacenters: pulumi.StringArray{
				pulumi.String("dc1"),
			},
		})
		if err != nil {
			return err
		}
		_, err = consul.NewAclRole(ctx, "read", &consul.AclRoleArgs{
			Name:        pulumi.String("foo"),
			Description: pulumi.String("bar"),
			Policies: pulumi.StringArray{
				read_policy.ID(),
			},
			ServiceIdentities: consul.AclRoleServiceIdentityArray{
				&consul.AclRoleServiceIdentityArgs{
					ServiceName: pulumi.String("foo"),
				},
			},
		})
		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 read_policy = new Consul.AclPolicy("read-policy", new()
    {
        Name = "read-policy",
        Rules = "node \"\" { policy = \"read\" }",
        Datacenters = new[]
        {
            "dc1",
        },
    });

    var read = new Consul.AclRole("read", new()
    {
        Name = "foo",
        Description = "bar",
        Policies = new[]
        {
            read_policy.Id,
        },
        ServiceIdentities = new[]
        {
            new Consul.Inputs.AclRoleServiceIdentityArgs
            {
                ServiceName = "foo",
            },
        },
    });

});
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 com.pulumi.consul.AclRole;
import com.pulumi.consul.AclRoleArgs;
import com.pulumi.consul.inputs.AclRoleServiceIdentityArgs;
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 read_policy = new AclPolicy("read-policy", AclPolicyArgs.builder()
            .name("read-policy")
            .rules("node \"\" { policy = \"read\" }")
            .datacenters("dc1")
            .build());

        var read = new AclRole("read", AclRoleArgs.builder()
            .name("foo")
            .description("bar")
            .policies(read_policy.id())
            .serviceIdentities(AclRoleServiceIdentityArgs.builder()
                .serviceName("foo")
                .build())
            .build());

    }
}
Copy
resources:
  read-policy:
    type: consul:AclPolicy
    properties:
      name: read-policy
      rules: node "" { policy = "read" }
      datacenters:
        - dc1
  read:
    type: consul:AclRole
    properties:
      name: foo
      description: bar
      policies:
        - ${["read-policy"].id}
      serviceIdentities:
        - serviceName: foo
Copy

Create AclRole Resource

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

Constructor syntax

new AclRole(name: string, args?: AclRoleArgs, opts?: CustomResourceOptions);
@overload
def AclRole(resource_name: str,
            args: Optional[AclRoleArgs] = None,
            opts: Optional[ResourceOptions] = None)

@overload
def AclRole(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            namespace: Optional[str] = None,
            node_identities: Optional[Sequence[AclRoleNodeIdentityArgs]] = None,
            partition: Optional[str] = None,
            policies: Optional[Sequence[str]] = None,
            service_identities: Optional[Sequence[AclRoleServiceIdentityArgs]] = None,
            templated_policies: Optional[Sequence[AclRoleTemplatedPolicyArgs]] = None)
func NewAclRole(ctx *Context, name string, args *AclRoleArgs, opts ...ResourceOption) (*AclRole, error)
public AclRole(string name, AclRoleArgs? args = null, CustomResourceOptions? opts = null)
public AclRole(String name, AclRoleArgs args)
public AclRole(String name, AclRoleArgs args, CustomResourceOptions options)
type: consul:AclRole
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 AclRoleArgs
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 AclRoleArgs
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 AclRoleArgs
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 AclRoleArgs
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. AclRoleArgs
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 aclRoleResource = new Consul.AclRole("aclRoleResource", new()
{
    Description = "string",
    Name = "string",
    Namespace = "string",
    NodeIdentities = new[]
    {
        new Consul.Inputs.AclRoleNodeIdentityArgs
        {
            Datacenter = "string",
            NodeName = "string",
        },
    },
    Partition = "string",
    Policies = new[]
    {
        "string",
    },
    ServiceIdentities = new[]
    {
        new Consul.Inputs.AclRoleServiceIdentityArgs
        {
            ServiceName = "string",
            Datacenters = new[]
            {
                "string",
            },
        },
    },
    TemplatedPolicies = new[]
    {
        new Consul.Inputs.AclRoleTemplatedPolicyArgs
        {
            TemplateName = "string",
            Datacenters = new[]
            {
                "string",
            },
            TemplateVariables = new Consul.Inputs.AclRoleTemplatedPolicyTemplateVariablesArgs
            {
                Name = "string",
            },
        },
    },
});
Copy
example, err := consul.NewAclRole(ctx, "aclRoleResource", &consul.AclRoleArgs{
	Description: pulumi.String("string"),
	Name:        pulumi.String("string"),
	Namespace:   pulumi.String("string"),
	NodeIdentities: consul.AclRoleNodeIdentityArray{
		&consul.AclRoleNodeIdentityArgs{
			Datacenter: pulumi.String("string"),
			NodeName:   pulumi.String("string"),
		},
	},
	Partition: pulumi.String("string"),
	Policies: pulumi.StringArray{
		pulumi.String("string"),
	},
	ServiceIdentities: consul.AclRoleServiceIdentityArray{
		&consul.AclRoleServiceIdentityArgs{
			ServiceName: pulumi.String("string"),
			Datacenters: pulumi.StringArray{
				pulumi.String("string"),
			},
		},
	},
	TemplatedPolicies: consul.AclRoleTemplatedPolicyArray{
		&consul.AclRoleTemplatedPolicyArgs{
			TemplateName: pulumi.String("string"),
			Datacenters: pulumi.StringArray{
				pulumi.String("string"),
			},
			TemplateVariables: &consul.AclRoleTemplatedPolicyTemplateVariablesArgs{
				Name: pulumi.String("string"),
			},
		},
	},
})
Copy
var aclRoleResource = new AclRole("aclRoleResource", AclRoleArgs.builder()
    .description("string")
    .name("string")
    .namespace("string")
    .nodeIdentities(AclRoleNodeIdentityArgs.builder()
        .datacenter("string")
        .nodeName("string")
        .build())
    .partition("string")
    .policies("string")
    .serviceIdentities(AclRoleServiceIdentityArgs.builder()
        .serviceName("string")
        .datacenters("string")
        .build())
    .templatedPolicies(AclRoleTemplatedPolicyArgs.builder()
        .templateName("string")
        .datacenters("string")
        .templateVariables(AclRoleTemplatedPolicyTemplateVariablesArgs.builder()
            .name("string")
            .build())
        .build())
    .build());
Copy
acl_role_resource = consul.AclRole("aclRoleResource",
    description="string",
    name="string",
    namespace="string",
    node_identities=[{
        "datacenter": "string",
        "node_name": "string",
    }],
    partition="string",
    policies=["string"],
    service_identities=[{
        "service_name": "string",
        "datacenters": ["string"],
    }],
    templated_policies=[{
        "template_name": "string",
        "datacenters": ["string"],
        "template_variables": {
            "name": "string",
        },
    }])
Copy
const aclRoleResource = new consul.AclRole("aclRoleResource", {
    description: "string",
    name: "string",
    namespace: "string",
    nodeIdentities: [{
        datacenter: "string",
        nodeName: "string",
    }],
    partition: "string",
    policies: ["string"],
    serviceIdentities: [{
        serviceName: "string",
        datacenters: ["string"],
    }],
    templatedPolicies: [{
        templateName: "string",
        datacenters: ["string"],
        templateVariables: {
            name: "string",
        },
    }],
});
Copy
type: consul:AclRole
properties:
    description: string
    name: string
    namespace: string
    nodeIdentities:
        - datacenter: string
          nodeName: string
    partition: string
    policies:
        - string
    serviceIdentities:
        - datacenters:
            - string
          serviceName: string
    templatedPolicies:
        - datacenters:
            - string
          templateName: string
          templateVariables:
            name: string
Copy

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

Description string
A free form human readable description of the role.
Name string
The name of the ACL role.
Namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
NodeIdentities List<AclRoleNodeIdentity>
The list of node identities that should be applied to the role.
Partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
Policies List<string>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
ServiceIdentities List<AclRoleServiceIdentity>
The list of service identities that should be applied to the role.
TemplatedPolicies List<AclRoleTemplatedPolicy>
The list of templated policies that should be applied to the token.
Description string
A free form human readable description of the role.
Name string
The name of the ACL role.
Namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
NodeIdentities []AclRoleNodeIdentityArgs
The list of node identities that should be applied to the role.
Partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
Policies []string
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
ServiceIdentities []AclRoleServiceIdentityArgs
The list of service identities that should be applied to the role.
TemplatedPolicies []AclRoleTemplatedPolicyArgs
The list of templated policies that should be applied to the token.
description String
A free form human readable description of the role.
name String
The name of the ACL role.
namespace Changes to this property will trigger replacement. String
The namespace to create the role within.
nodeIdentities List<AclRoleNodeIdentity>
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. String
The partition the ACL role is associated with.
policies List<String>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities List<AclRoleServiceIdentity>
The list of service identities that should be applied to the role.
templatedPolicies List<AclRoleTemplatedPolicy>
The list of templated policies that should be applied to the token.
description string
A free form human readable description of the role.
name string
The name of the ACL role.
namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
nodeIdentities AclRoleNodeIdentity[]
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
policies string[]
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities AclRoleServiceIdentity[]
The list of service identities that should be applied to the role.
templatedPolicies AclRoleTemplatedPolicy[]
The list of templated policies that should be applied to the token.
description str
A free form human readable description of the role.
name str
The name of the ACL role.
namespace Changes to this property will trigger replacement. str
The namespace to create the role within.
node_identities Sequence[AclRoleNodeIdentityArgs]
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. str
The partition the ACL role is associated with.
policies Sequence[str]
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
service_identities Sequence[AclRoleServiceIdentityArgs]
The list of service identities that should be applied to the role.
templated_policies Sequence[AclRoleTemplatedPolicyArgs]
The list of templated policies that should be applied to the token.
description String
A free form human readable description of the role.
name String
The name of the ACL role.
namespace Changes to this property will trigger replacement. String
The namespace to create the role within.
nodeIdentities List<Property Map>
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. String
The partition the ACL role is associated with.
policies List<String>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities List<Property Map>
The list of service identities that should be applied to the role.
templatedPolicies List<Property Map>
The list of templated policies that should be applied to the token.

Outputs

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

Get an existing AclRole 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?: AclRoleState, opts?: CustomResourceOptions): AclRole
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        namespace: Optional[str] = None,
        node_identities: Optional[Sequence[AclRoleNodeIdentityArgs]] = None,
        partition: Optional[str] = None,
        policies: Optional[Sequence[str]] = None,
        service_identities: Optional[Sequence[AclRoleServiceIdentityArgs]] = None,
        templated_policies: Optional[Sequence[AclRoleTemplatedPolicyArgs]] = None) -> AclRole
func GetAclRole(ctx *Context, name string, id IDInput, state *AclRoleState, opts ...ResourceOption) (*AclRole, error)
public static AclRole Get(string name, Input<string> id, AclRoleState? state, CustomResourceOptions? opts = null)
public static AclRole get(String name, Output<String> id, AclRoleState state, CustomResourceOptions options)
resources:  _:    type: consul:AclRole    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:
Description string
A free form human readable description of the role.
Name string
The name of the ACL role.
Namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
NodeIdentities List<AclRoleNodeIdentity>
The list of node identities that should be applied to the role.
Partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
Policies List<string>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
ServiceIdentities List<AclRoleServiceIdentity>
The list of service identities that should be applied to the role.
TemplatedPolicies List<AclRoleTemplatedPolicy>
The list of templated policies that should be applied to the token.
Description string
A free form human readable description of the role.
Name string
The name of the ACL role.
Namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
NodeIdentities []AclRoleNodeIdentityArgs
The list of node identities that should be applied to the role.
Partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
Policies []string
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
ServiceIdentities []AclRoleServiceIdentityArgs
The list of service identities that should be applied to the role.
TemplatedPolicies []AclRoleTemplatedPolicyArgs
The list of templated policies that should be applied to the token.
description String
A free form human readable description of the role.
name String
The name of the ACL role.
namespace Changes to this property will trigger replacement. String
The namespace to create the role within.
nodeIdentities List<AclRoleNodeIdentity>
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. String
The partition the ACL role is associated with.
policies List<String>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities List<AclRoleServiceIdentity>
The list of service identities that should be applied to the role.
templatedPolicies List<AclRoleTemplatedPolicy>
The list of templated policies that should be applied to the token.
description string
A free form human readable description of the role.
name string
The name of the ACL role.
namespace Changes to this property will trigger replacement. string
The namespace to create the role within.
nodeIdentities AclRoleNodeIdentity[]
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. string
The partition the ACL role is associated with.
policies string[]
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities AclRoleServiceIdentity[]
The list of service identities that should be applied to the role.
templatedPolicies AclRoleTemplatedPolicy[]
The list of templated policies that should be applied to the token.
description str
A free form human readable description of the role.
name str
The name of the ACL role.
namespace Changes to this property will trigger replacement. str
The namespace to create the role within.
node_identities Sequence[AclRoleNodeIdentityArgs]
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. str
The partition the ACL role is associated with.
policies Sequence[str]
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
service_identities Sequence[AclRoleServiceIdentityArgs]
The list of service identities that should be applied to the role.
templated_policies Sequence[AclRoleTemplatedPolicyArgs]
The list of templated policies that should be applied to the token.
description String
A free form human readable description of the role.
name String
The name of the ACL role.
namespace Changes to this property will trigger replacement. String
The namespace to create the role within.
nodeIdentities List<Property Map>
The list of node identities that should be applied to the role.
partition Changes to this property will trigger replacement. String
The partition the ACL role is associated with.
policies List<String>
The list of policies that should be applied to the role. Both the policy ID or its name can be used.
serviceIdentities List<Property Map>
The list of service identities that should be applied to the role.
templatedPolicies List<Property Map>
The list of templated policies that should be applied to the token.

Supporting Types

AclRoleNodeIdentity
, AclRoleNodeIdentityArgs

Datacenter This property is required. string
Specifies the node's datacenter.
NodeName This property is required. string
The name of the node.
Datacenter This property is required. string
Specifies the node's datacenter.
NodeName This property is required. string
The name of the node.
datacenter This property is required. String
Specifies the node's datacenter.
nodeName This property is required. String
The name of the node.
datacenter This property is required. string
Specifies the node's datacenter.
nodeName This property is required. string
The name of the node.
datacenter This property is required. str
Specifies the node's datacenter.
node_name This property is required. str
The name of the node.
datacenter This property is required. String
Specifies the node's datacenter.
nodeName This property is required. String
The name of the node.

AclRoleServiceIdentity
, AclRoleServiceIdentityArgs

ServiceName This property is required. string
The name of the service.
Datacenters List<string>
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
ServiceName This property is required. string
The name of the service.
Datacenters []string
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
serviceName This property is required. String
The name of the service.
datacenters List<String>
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
serviceName This property is required. string
The name of the service.
datacenters string[]
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
service_name This property is required. str
The name of the service.
datacenters Sequence[str]
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
serviceName This property is required. String
The name of the service.
datacenters List<String>
The datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.

AclRoleTemplatedPolicy
, AclRoleTemplatedPolicyArgs

TemplateName This property is required. string
The name of the templated policies.
Datacenters List<string>
Specifies the datacenters the effective policy is valid within.
TemplateVariables AclRoleTemplatedPolicyTemplateVariables
The templated policy variables.
TemplateName This property is required. string
The name of the templated policies.
Datacenters []string
Specifies the datacenters the effective policy is valid within.
TemplateVariables AclRoleTemplatedPolicyTemplateVariables
The templated policy variables.
templateName This property is required. String
The name of the templated policies.
datacenters List<String>
Specifies the datacenters the effective policy is valid within.
templateVariables AclRoleTemplatedPolicyTemplateVariables
The templated policy variables.
templateName This property is required. string
The name of the templated policies.
datacenters string[]
Specifies the datacenters the effective policy is valid within.
templateVariables AclRoleTemplatedPolicyTemplateVariables
The templated policy variables.
template_name This property is required. str
The name of the templated policies.
datacenters Sequence[str]
Specifies the datacenters the effective policy is valid within.
template_variables AclRoleTemplatedPolicyTemplateVariables
The templated policy variables.
templateName This property is required. String
The name of the templated policies.
datacenters List<String>
Specifies the datacenters the effective policy is valid within.
templateVariables Property Map
The templated policy variables.

AclRoleTemplatedPolicyTemplateVariables
, AclRoleTemplatedPolicyTemplateVariablesArgs

Name string
The name of node, workload identity or service.
Name string
The name of node, workload identity or service.
name String
The name of node, workload identity or service.
name string
The name of node, workload identity or service.
name str
The name of node, workload identity or service.
name String
The name of node, workload identity or service.

Import

$ pulumi import consul:index/aclRole:AclRole read 816a195f-6cb1-2e8d-92af-3011ae706318
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.