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

consul.AgentService

Explore with Pulumi AI

!> The consul.AgentService resource has been deprecated in version 2.0.0 of the provider and will be removed in a future release. Please read the upgrade guide for more information.

Provides access to the agent service data in Consul. This can be used to define a service associated with a particular agent. Currently, defining health checks for an agent service is not supported.

Example Usage

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

const app = new consul.AgentService("app", {
    address: "www.google.com",
    name: "google",
    port: 80,
    tags: [
        "tag0",
        "tag1",
    ],
});
Copy
import pulumi
import pulumi_consul as consul

app = consul.AgentService("app",
    address="www.google.com",
    name="google",
    port=80,
    tags=[
        "tag0",
        "tag1",
    ])
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.NewAgentService(ctx, "app", &consul.AgentServiceArgs{
			Address: pulumi.String("www.google.com"),
			Name:    pulumi.String("google"),
			Port:    pulumi.Int(80),
			Tags: pulumi.StringArray{
				pulumi.String("tag0"),
				pulumi.String("tag1"),
			},
		})
		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 app = new Consul.AgentService("app", new()
    {
        Address = "www.google.com",
        Name = "google",
        Port = 80,
        Tags = new[]
        {
            "tag0",
            "tag1",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.AgentService;
import com.pulumi.consul.AgentServiceArgs;
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 app = new AgentService("app", AgentServiceArgs.builder()
            .address("www.google.com")
            .name("google")
            .port(80)
            .tags(            
                "tag0",
                "tag1")
            .build());

    }
}
Copy
resources:
  app:
    type: consul:AgentService
    properties:
      address: www.google.com
      name: google
      port: 80
      tags:
        - tag0
        - tag1
Copy

Create AgentService Resource

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

Constructor syntax

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

@overload
def AgentService(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 address: Optional[str] = None,
                 name: Optional[str] = None,
                 port: Optional[int] = None,
                 tags: Optional[Sequence[str]] = None)
func NewAgentService(ctx *Context, name string, args *AgentServiceArgs, opts ...ResourceOption) (*AgentService, error)
public AgentService(string name, AgentServiceArgs? args = null, CustomResourceOptions? opts = null)
public AgentService(String name, AgentServiceArgs args)
public AgentService(String name, AgentServiceArgs args, CustomResourceOptions options)
type: consul:AgentService
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 AgentServiceArgs
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 AgentServiceArgs
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 AgentServiceArgs
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 AgentServiceArgs
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. AgentServiceArgs
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 agentServiceResource = new Consul.AgentService("agentServiceResource", new()
{
    Address = "string",
    Name = "string",
    Port = 0,
    Tags = new[]
    {
        "string",
    },
});
Copy
example, err := consul.NewAgentService(ctx, "agentServiceResource", &consul.AgentServiceArgs{
	Address: pulumi.String("string"),
	Name:    pulumi.String("string"),
	Port:    pulumi.Int(0),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var agentServiceResource = new AgentService("agentServiceResource", AgentServiceArgs.builder()
    .address("string")
    .name("string")
    .port(0)
    .tags("string")
    .build());
Copy
agent_service_resource = consul.AgentService("agentServiceResource",
    address="string",
    name="string",
    port=0,
    tags=["string"])
Copy
const agentServiceResource = new consul.AgentService("agentServiceResource", {
    address: "string",
    name: "string",
    port: 0,
    tags: ["string"],
});
Copy
type: consul:AgentService
properties:
    address: string
    name: string
    port: 0
    tags:
        - string
Copy

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

Address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
Name string
The name of the service.
Port Changes to this property will trigger replacement. int
The port of the service.
Tags Changes to this property will trigger replacement. List<string>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
Address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
Name string
The name of the service.
Port Changes to this property will trigger replacement. int
The port of the service.
Tags Changes to this property will trigger replacement. []string
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. String
The address of the service. Defaults to the address of the agent.
name String
The name of the service.
port Changes to this property will trigger replacement. Integer
The port of the service.
tags Changes to this property will trigger replacement. List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
name string
The name of the service.
port Changes to this property will trigger replacement. number
The port of the service.
tags Changes to this property will trigger replacement. string[]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. str
The address of the service. Defaults to the address of the agent.
name str
The name of the service.
port Changes to this property will trigger replacement. int
The port of the service.
tags Changes to this property will trigger replacement. Sequence[str]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. String
The address of the service. Defaults to the address of the agent.
name String
The name of the service.
port Changes to this property will trigger replacement. Number
The port of the service.
tags Changes to this property will trigger replacement. List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.

Outputs

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

Get an existing AgentService 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?: AgentServiceState, opts?: CustomResourceOptions): AgentService
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        address: Optional[str] = None,
        name: Optional[str] = None,
        port: Optional[int] = None,
        tags: Optional[Sequence[str]] = None) -> AgentService
func GetAgentService(ctx *Context, name string, id IDInput, state *AgentServiceState, opts ...ResourceOption) (*AgentService, error)
public static AgentService Get(string name, Input<string> id, AgentServiceState? state, CustomResourceOptions? opts = null)
public static AgentService get(String name, Output<String> id, AgentServiceState state, CustomResourceOptions options)
resources:  _:    type: consul:AgentService    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:
Address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
Name string
The name of the service.
Port Changes to this property will trigger replacement. int
The port of the service.
Tags Changes to this property will trigger replacement. List<string>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
Address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
Name string
The name of the service.
Port Changes to this property will trigger replacement. int
The port of the service.
Tags Changes to this property will trigger replacement. []string
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. String
The address of the service. Defaults to the address of the agent.
name String
The name of the service.
port Changes to this property will trigger replacement. Integer
The port of the service.
tags Changes to this property will trigger replacement. List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. string
The address of the service. Defaults to the address of the agent.
name string
The name of the service.
port Changes to this property will trigger replacement. number
The port of the service.
tags Changes to this property will trigger replacement. string[]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. str
The address of the service. Defaults to the address of the agent.
name str
The name of the service.
port Changes to this property will trigger replacement. int
The port of the service.
tags Changes to this property will trigger replacement. Sequence[str]
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
address Changes to this property will trigger replacement. String
The address of the service. Defaults to the address of the agent.
name String
The name of the service.
port Changes to this property will trigger replacement. Number
The port of the service.
tags Changes to this property will trigger replacement. List<String>
A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.

Package Details

Repository
HashiCorp Consul pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.