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

consul.getNetworkSegments

Explore with Pulumi AI

Consul v3.12.4 published on Wednesday, Feb 12, 2025 by Pulumi

NOTE: This feature requires Consul Enterprise.

The consul_network_segment data source can be used to retrieve the network segments defined in the configuration.

Example Usage

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

export = async () => {
    const segments = await consul.getNetworkSegments({});
    return {
        segments: segments.segments,
    };
}
Copy
import pulumi
import pulumi_consul as consul

segments = consul.get_network_segments()
pulumi.export("segments", segments.segments)
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 {
		segments, err := consul.GetNetworkSegments(ctx, &consul.GetNetworkSegmentsArgs{}, nil)
		if err != nil {
			return err
		}
		ctx.Export("segments", segments.Segments)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;

return await Deployment.RunAsync(() => 
{
    var segments = Consul.GetNetworkSegments.Invoke();

    return new Dictionary<string, object?>
    {
        ["segments"] = segments.Apply(getNetworkSegmentsResult => getNetworkSegmentsResult.Segments),
    };
});
Copy
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.GetNetworkSegmentsArgs;
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 segments = ConsulFunctions.getNetworkSegments();

        ctx.export("segments", segments.applyValue(getNetworkSegmentsResult -> getNetworkSegmentsResult.segments()));
    }
}
Copy
variables:
  segments:
    fn::invoke:
      function: consul:getNetworkSegments
      arguments: {}
outputs:
  segments: ${segments.segments}
Copy

Using getNetworkSegments

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getNetworkSegments(args: GetNetworkSegmentsArgs, opts?: InvokeOptions): Promise<GetNetworkSegmentsResult>
function getNetworkSegmentsOutput(args: GetNetworkSegmentsOutputArgs, opts?: InvokeOptions): Output<GetNetworkSegmentsResult>
Copy
def get_network_segments(datacenter: Optional[str] = None,
                         token: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetNetworkSegmentsResult
def get_network_segments_output(datacenter: Optional[pulumi.Input[str]] = None,
                         token: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetNetworkSegmentsResult]
Copy
func GetNetworkSegments(ctx *Context, args *GetNetworkSegmentsArgs, opts ...InvokeOption) (*GetNetworkSegmentsResult, error)
func GetNetworkSegmentsOutput(ctx *Context, args *GetNetworkSegmentsOutputArgs, opts ...InvokeOption) GetNetworkSegmentsResultOutput
Copy

> Note: This function is named GetNetworkSegments in the Go SDK.

public static class GetNetworkSegments 
{
    public static Task<GetNetworkSegmentsResult> InvokeAsync(GetNetworkSegmentsArgs args, InvokeOptions? opts = null)
    public static Output<GetNetworkSegmentsResult> Invoke(GetNetworkSegmentsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetNetworkSegmentsResult> getNetworkSegments(GetNetworkSegmentsArgs args, InvokeOptions options)
public static Output<GetNetworkSegmentsResult> getNetworkSegments(GetNetworkSegmentsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: consul:index/getNetworkSegments:getNetworkSegments
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Datacenter string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Datacenter string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter str
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
token str
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

getNetworkSegments Result

The following output properties are available:

Datacenter string
The datacenter the segments are being read from.
Id string
The provider-assigned unique ID for this managed resource.
Segments List<string>
The list of network segments.
Token string

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Datacenter string
The datacenter the segments are being read from.
Id string
The provider-assigned unique ID for this managed resource.
Segments []string
The list of network segments.
Token string

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter String
The datacenter the segments are being read from.
id String
The provider-assigned unique ID for this managed resource.
segments List<String>
The list of network segments.
token String

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter string
The datacenter the segments are being read from.
id string
The provider-assigned unique ID for this managed resource.
segments string[]
The list of network segments.
token string

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter str
The datacenter the segments are being read from.
id str
The provider-assigned unique ID for this managed resource.
segments Sequence[str]
The list of network segments.
token str

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter String
The datacenter the segments are being read from.
id String
The provider-assigned unique ID for this managed resource.
segments List<String>
The list of network segments.
token String

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Package Details

Repository
HashiCorp Consul pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.
Consul v3.12.4 published on Wednesday, Feb 12, 2025 by Pulumi