Dynatrace

v0.0.2 published on Tuesday, Nov 1, 2022 by Lbrlabs

getHost

The host data source allows the host ID to be retrieved by its name and optionally tags / tag-value pairs.

  • name queries for all hosts with the specified name
  • tags (optional) refers to the tags that need to be present for the host (inclusive)

If multiple hosts match the given criteria, the first result will be retrieved.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Dynatrace = Lbrlabs.PulumiPackage.Dynatrace;
using Dynatrace = Pulumi.Dynatrace;

return await Deployment.RunAsync(() => 
{
    var test = Dynatrace.GetHost.Invoke(new()
    {
        Name = "Example",
        Tags = new[]
        {
            "TerraformKeyTest",
            "TerraformKeyValueTest=TestValue",
        },
    });

    var _name_ = new Dynatrace.ManagementZone("#name#", new()
    {
        EntitySelectorBasedRules = new[]
        {
            new Dynatrace.Inputs.ManagementZoneEntitySelectorBasedRuleArgs
            {
                Enabled = true,
                Selector = $"type(\"host\"),entityId(\"{test.Apply(getHostResult => getHostResult.Id)}\")",
            },
        },
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-dynatrace/sdk/go/dynatrace"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := dynatrace.GetHost(ctx, &GetHostArgs{
			Name: "Example",
			Tags: []string{
				"TerraformKeyTest",
				"TerraformKeyValueTest=TestValue",
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = dynatrace.NewManagementZone(ctx, "#name#", &dynatrace.ManagementZoneArgs{
			EntitySelectorBasedRules: ManagementZoneEntitySelectorBasedRuleArray{
				&ManagementZoneEntitySelectorBasedRuleArgs{
					Enabled:  pulumi.Bool(true),
					Selector: pulumi.String(fmt.Sprintf("type(\"host\"),entityId(\"%v\")", test.Id)),
				},
			},
		})
		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.dynatrace.DynatraceFunctions;
import com.pulumi.dynatrace.inputs.GetHostArgs;
import com.pulumi.dynatrace.ManagementZone;
import com.pulumi.dynatrace.ManagementZoneArgs;
import com.pulumi.dynatrace.inputs.ManagementZoneEntitySelectorBasedRuleArgs;
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 test = DynatraceFunctions.getHost(GetHostArgs.builder()
            .name("Example")
            .tags(            
                "TerraformKeyTest",
                "TerraformKeyValueTest=TestValue")
            .build());

        var _name_ = new ManagementZone("#name#", ManagementZoneArgs.builder()        
            .entitySelectorBasedRules(ManagementZoneEntitySelectorBasedRuleArgs.builder()
                .enabled(true)
                .selector(String.format("type(\"host\"),entityId(\"%s\")", test.applyValue(getHostResult -> getHostResult.id())))
                .build())
            .build());

    }
}
import pulumi
import lbrlabs_pulumi_dynatrace as dynatrace
import pulumi_dynatrace as dynatrace

test = dynatrace.get_host(name="Example",
    tags=[
        "TerraformKeyTest",
        "TerraformKeyValueTest=TestValue",
    ])
_name_ = dynatrace.ManagementZone("#name#", entity_selector_based_rules=[dynatrace.ManagementZoneEntitySelectorBasedRuleArgs(
    enabled=True,
    selector=f"type(\"host\"),entityId(\"{test.id}\")",
)])
import * as pulumi from "@pulumi/pulumi";
import * as dynatrace from "@pulumi/dynatrace";

const test = pulumi.output(dynatrace.getHost({
    name: "Example",
    tags: [
        "TerraformKeyTest",
        "TerraformKeyValueTest=TestValue",
    ],
}));
const _name_ = new dynatrace.ManagementZone("#name#", {
    entitySelectorBasedRules: [{
        enabled: true,
        selector: pulumi.interpolate`type("host"),entityId("${test.id}")`,
    }],
});
resources:
  '#name#':
    type: dynatrace:ManagementZone
    properties:
      entitySelectorBasedRules:
        - enabled: true
          selector: type("host"),entityId("${test.id}")
variables:
  test:
    fn::invoke:
      Function: dynatrace:getHost
      Arguments:
        name: Example
        tags:
          - TerraformKeyTest
          - TerraformKeyValueTest=TestValue

Using getHost

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 getHost(args: GetHostArgs, opts?: InvokeOptions): Promise<GetHostResult>
function getHostOutput(args: GetHostOutputArgs, opts?: InvokeOptions): Output<GetHostResult>
def get_host(name: Optional[str] = None,
             tags: Optional[Sequence[str]] = None,
             opts: Optional[InvokeOptions] = None) -> GetHostResult
def get_host_output(name: Optional[pulumi.Input[str]] = None,
             tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetHostResult]
func GetHost(ctx *Context, args *GetHostArgs, opts ...InvokeOption) (*GetHostResult, error)
func GetHostOutput(ctx *Context, args *GetHostOutputArgs, opts ...InvokeOption) GetHostResultOutput

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

public static class GetHost 
{
    public static Task<GetHostResult> InvokeAsync(GetHostArgs args, InvokeOptions? opts = null)
    public static Output<GetHostResult> Invoke(GetHostInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetHostResult> getHost(GetHostArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: dynatrace:index/getHost:getHost
  arguments:
    # arguments dictionary

The following arguments are supported:

Name string
Tags List<string>

Required tags of the host to find

Name string
Tags []string

Required tags of the host to find

name String
tags List<String>

Required tags of the host to find

name string
tags string[]

Required tags of the host to find

name str
tags Sequence[str]

Required tags of the host to find

name String
tags List<String>

Required tags of the host to find

getHost Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Name string
Tags List<string>

Required tags of the host to find

Id string

The provider-assigned unique ID for this managed resource.

Name string
Tags []string

Required tags of the host to find

id String

The provider-assigned unique ID for this managed resource.

name String
tags List<String>

Required tags of the host to find

id string

The provider-assigned unique ID for this managed resource.

name string
tags string[]

Required tags of the host to find

id str

The provider-assigned unique ID for this managed resource.

name str
tags Sequence[str]

Required tags of the host to find

id String

The provider-assigned unique ID for this managed resource.

name String
tags List<String>

Required tags of the host to find

Package Details

Repository
https://github.com/lbrlabs/pulumi-dynatrace
License
Apache-2.0
Notes

This Pulumi package is based on the dynatrace Terraform Provider.