1. Packages
  2. HashiCorp Consul
  3. API Docs
  4. AclRolePolicyAttachment
Consul v3.11.3 published on Friday, May 24, 2024 by Pulumi

consul.AclRolePolicyAttachment

Explore with Pulumi AI

consul logo
Consul v3.11.3 published on Friday, May 24, 2024 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as consul from "@pulumi/consul";
    
    const myRole = consul.getAclRole({
        name: "my_role",
    });
    const readPolicy = new consul.AclPolicy("read_policy", {
        name: "read-policy",
        rules: "node \"\" { policy = \"read\" }",
        datacenters: ["dc1"],
    });
    const myRoleReadPolicy = new consul.AclRolePolicyAttachment("my_role_read_policy", {
        roleId: test.id,
        policy: readPolicy.name,
    });
    
    import pulumi
    import pulumi_consul as consul
    
    my_role = consul.get_acl_role(name="my_role")
    read_policy = consul.AclPolicy("read_policy",
        name="read-policy",
        rules="node \"\" { policy = \"read\" }",
        datacenters=["dc1"])
    my_role_read_policy = consul.AclRolePolicyAttachment("my_role_read_policy",
        role_id=test["id"],
        policy=read_policy.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 {
    		_, err := consul.LookupAclRole(ctx, &consul.LookupAclRoleArgs{
    			Name: "my_role",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		readPolicy, 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.NewAclRolePolicyAttachment(ctx, "my_role_read_policy", &consul.AclRolePolicyAttachmentArgs{
    			RoleId: pulumi.Any(test.Id),
    			Policy: readPolicy.Name,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Consul = Pulumi.Consul;
    
    return await Deployment.RunAsync(() => 
    {
        var myRole = Consul.GetAclRole.Invoke(new()
        {
            Name = "my_role",
        });
    
        var readPolicy = new Consul.AclPolicy("read_policy", new()
        {
            Name = "read-policy",
            Rules = "node \"\" { policy = \"read\" }",
            Datacenters = new[]
            {
                "dc1",
            },
        });
    
        var myRoleReadPolicy = new Consul.AclRolePolicyAttachment("my_role_read_policy", new()
        {
            RoleId = test.Id,
            Policy = readPolicy.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.consul.ConsulFunctions;
    import com.pulumi.consul.inputs.GetAclRoleArgs;
    import com.pulumi.consul.AclPolicy;
    import com.pulumi.consul.AclPolicyArgs;
    import com.pulumi.consul.AclRolePolicyAttachment;
    import com.pulumi.consul.AclRolePolicyAttachmentArgs;
    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) {
            final var myRole = ConsulFunctions.getAclRole(GetAclRoleArgs.builder()
                .name("my_role")
                .build());
    
            var readPolicy = new AclPolicy("readPolicy", AclPolicyArgs.builder()
                .name("read-policy")
                .rules("node \"\" { policy = \"read\" }")
                .datacenters("dc1")
                .build());
    
            var myRoleReadPolicy = new AclRolePolicyAttachment("myRoleReadPolicy", AclRolePolicyAttachmentArgs.builder()
                .roleId(test.id())
                .policy(readPolicy.name())
                .build());
    
        }
    }
    
    resources:
      readPolicy:
        type: consul:AclPolicy
        name: read_policy
        properties:
          name: read-policy
          rules: node "" { policy = "read" }
          datacenters:
            - dc1
      myRoleReadPolicy:
        type: consul:AclRolePolicyAttachment
        name: my_role_read_policy
        properties:
          roleId: ${test.id}
          policy: ${readPolicy.name}
    variables:
      myRole:
        fn::invoke:
          Function: consul:getAclRole
          Arguments:
            name: my_role
    

    Create AclRolePolicyAttachment Resource

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

    Constructor syntax

    new AclRolePolicyAttachment(name: string, args: AclRolePolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def AclRolePolicyAttachment(resource_name: str,
                                args: AclRolePolicyAttachmentArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def AclRolePolicyAttachment(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                policy: Optional[str] = None,
                                role_id: Optional[str] = None)
    func NewAclRolePolicyAttachment(ctx *Context, name string, args AclRolePolicyAttachmentArgs, opts ...ResourceOption) (*AclRolePolicyAttachment, error)
    public AclRolePolicyAttachment(string name, AclRolePolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public AclRolePolicyAttachment(String name, AclRolePolicyAttachmentArgs args)
    public AclRolePolicyAttachment(String name, AclRolePolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: consul:AclRolePolicyAttachment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args AclRolePolicyAttachmentArgs
    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 AclRolePolicyAttachmentArgs
    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 AclRolePolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AclRolePolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AclRolePolicyAttachmentArgs
    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 aclRolePolicyAttachmentResource = new Consul.AclRolePolicyAttachment("aclRolePolicyAttachmentResource", new()
    {
        Policy = "string",
        RoleId = "string",
    });
    
    example, err := consul.NewAclRolePolicyAttachment(ctx, "aclRolePolicyAttachmentResource", &consul.AclRolePolicyAttachmentArgs{
    	Policy: pulumi.String("string"),
    	RoleId: pulumi.String("string"),
    })
    
    var aclRolePolicyAttachmentResource = new AclRolePolicyAttachment("aclRolePolicyAttachmentResource", AclRolePolicyAttachmentArgs.builder()
        .policy("string")
        .roleId("string")
        .build());
    
    acl_role_policy_attachment_resource = consul.AclRolePolicyAttachment("aclRolePolicyAttachmentResource",
        policy="string",
        role_id="string")
    
    const aclRolePolicyAttachmentResource = new consul.AclRolePolicyAttachment("aclRolePolicyAttachmentResource", {
        policy: "string",
        roleId: "string",
    });
    
    type: consul:AclRolePolicyAttachment
    properties:
        policy: string
        roleId: string
    

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

    Policy string
    The policy name.
    RoleId string
    The id of the role.
    Policy string
    The policy name.
    RoleId string
    The id of the role.
    policy String
    The policy name.
    roleId String
    The id of the role.
    policy string
    The policy name.
    roleId string
    The id of the role.
    policy str
    The policy name.
    role_id str
    The id of the role.
    policy String
    The policy name.
    roleId String
    The id of the role.

    Outputs

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

    Get an existing AclRolePolicyAttachment 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?: AclRolePolicyAttachmentState, opts?: CustomResourceOptions): AclRolePolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy: Optional[str] = None,
            role_id: Optional[str] = None) -> AclRolePolicyAttachment
    func GetAclRolePolicyAttachment(ctx *Context, name string, id IDInput, state *AclRolePolicyAttachmentState, opts ...ResourceOption) (*AclRolePolicyAttachment, error)
    public static AclRolePolicyAttachment Get(string name, Input<string> id, AclRolePolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static AclRolePolicyAttachment get(String name, Output<String> id, AclRolePolicyAttachmentState 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.
    The following state arguments are supported:
    Policy string
    The policy name.
    RoleId string
    The id of the role.
    Policy string
    The policy name.
    RoleId string
    The id of the role.
    policy String
    The policy name.
    roleId String
    The id of the role.
    policy string
    The policy name.
    roleId string
    The id of the role.
    policy str
    The policy name.
    role_id str
    The id of the role.
    policy String
    The policy name.
    roleId String
    The id of the role.

    Import

    $ pulumi import consul:index/aclRolePolicyAttachment:AclRolePolicyAttachment my_role_read_policy 624d94ca-bc5c-f960-4e83-0a609cf588be:policy_name
    

    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.
    consul logo
    Consul v3.11.3 published on Friday, May 24, 2024 by Pulumi