Viewing docs for AWS v7.33.0
published on Monday, Jun 15, 2026 by Pulumi
published on Monday, Jun 15, 2026 by Pulumi
Viewing docs for AWS v7.33.0
published on Monday, Jun 15, 2026 by Pulumi
published on Monday, Jun 15, 2026 by Pulumi
Provides a list of EC2 Dedicated Host IDs matching the provided filters. More information about Dedicated Hosts can be found in the EC2 User Guide.
Example Usage
Filter by instance type
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.ec2.getHosts({
filters: [
{
name: "instance-type",
values: ["c5.large"],
},
{
name: "state",
values: ["available"],
},
],
});
import pulumi
import pulumi_aws as aws
example = aws.ec2.get_hosts(filters=[
{
"name": "instance-type",
"values": ["c5.large"],
},
{
"name": "state",
"values": ["available"],
},
])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.GetHosts(ctx, &ec2.GetHostsArgs{
Filters: []ec2.GetHostsFilter{
{
Name: "instance-type",
Values: []string{
"c5.large",
},
},
{
Name: "state",
Values: []string{
"available",
},
},
},
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Ec2.GetHosts.Invoke(new()
{
Filters = new[]
{
new Aws.Ec2.Inputs.GetHostsFilterInputArgs
{
Name = "instance-type",
Values = new[]
{
"c5.large",
},
},
new Aws.Ec2.Inputs.GetHostsFilterInputArgs
{
Name = "state",
Values = new[]
{
"available",
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetHostsArgs;
import com.pulumi.aws.ec2.inputs.GetHostsFilterArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 example = Ec2Functions.getHosts(GetHostsArgs.builder()
.filters(
GetHostsFilterArgs.builder()
.name("instance-type")
.values("c5.large")
.build(),
GetHostsFilterArgs.builder()
.name("state")
.values("available")
.build())
.build());
}
}
variables:
example:
fn::invoke:
function: aws:ec2:getHosts
arguments:
filters:
- name: instance-type
values:
- c5.large
- name: state
values:
- available
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_ec2_gethosts" "example" {
filters {
name = "instance-type"
values = ["c5.large"]
}
filters {
name = "state"
values = ["available"]
}
}
Filter by Outpost ARN
The outpostArn argument applies a client-side filter because the DescribeHosts API does not support outpost-arn as a server-side filter.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const outpost = aws.ec2.getHosts({
outpostArn: example.arn,
filters: [{
name: "state",
values: ["available"],
}],
});
import pulumi
import pulumi_aws as aws
outpost = aws.ec2.get_hosts(outpost_arn=example["arn"],
filters=[{
"name": "state",
"values": ["available"],
}])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.GetHosts(ctx, &ec2.GetHostsArgs{
OutpostArn: pulumi.StringRef(example.Arn),
Filters: []ec2.GetHostsFilter{
{
Name: "state",
Values: []string{
"available",
},
},
},
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var outpost = Aws.Ec2.GetHosts.Invoke(new()
{
OutpostArn = example.Arn,
Filters = new[]
{
new Aws.Ec2.Inputs.GetHostsFilterInputArgs
{
Name = "state",
Values = new[]
{
"available",
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetHostsArgs;
import com.pulumi.aws.ec2.inputs.GetHostsFilterArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 outpost = Ec2Functions.getHosts(GetHostsArgs.builder()
.outpostArn(example.arn())
.filters(GetHostsFilterArgs.builder()
.name("state")
.values("available")
.build())
.build());
}
}
variables:
outpost:
fn::invoke:
function: aws:ec2:getHosts
arguments:
outpostArn: ${example.arn}
filters:
- name: state
values:
- available
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_ec2_gethosts" "outpost" {
outpost_arn = example.arn
filters {
name = "state"
values = ["available"]
}
}
Using getHosts
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 getHosts(args: GetHostsArgs, opts?: InvokeOptions): Promise<GetHostsResult>
function getHostsOutput(args: GetHostsOutputArgs, opts?: InvokeOptions): Output<GetHostsResult>def get_hosts(filters: Optional[Sequence[GetHostsFilter]] = None,
outpost_arn: Optional[str] = None,
region: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetHostsResult
def get_hosts_output(filters: pulumi.Input[Optional[Sequence[pulumi.Input[GetHostsFilterArgs]]]] = None,
outpost_arn: pulumi.Input[Optional[str]] = None,
region: pulumi.Input[Optional[str]] = None,
tags: pulumi.Input[Optional[Mapping[str, pulumi.Input[str]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetHostsResult]func GetHosts(ctx *Context, args *GetHostsArgs, opts ...InvokeOption) (*GetHostsResult, error)
func GetHostsOutput(ctx *Context, args *GetHostsOutputArgs, opts ...InvokeOption) GetHostsResultOutput> Note: This function is named GetHosts in the Go SDK.
public static class GetHosts
{
public static Task<GetHostsResult> InvokeAsync(GetHostsArgs args, InvokeOptions? opts = null)
public static Output<GetHostsResult> Invoke(GetHostsInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetHostsResult> getHosts(GetHostsArgs args, InvokeOptions options)
public static Output<GetHostsResult> getHosts(GetHostsArgs args, InvokeOptions options)
fn::invoke:
function: aws:ec2/getHosts:getHosts
arguments:
# arguments dictionarydata "aws_ec2_gethosts" "name" {
# arguments
}The following arguments are supported:
- Filters
List<Get
Hosts Filter> - One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- Outpost
Arn string - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Dictionary<string, string>
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- Filters
[]Get
Hosts Filter - One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- Outpost
Arn string - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- map[string]string
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- filters list(object)
- One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- outpost_
arn string - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- map(string)
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- filters
List<Get
Hosts Filter> - One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- outpost
Arn String - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Map<String,String>
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- filters
Get
Hosts Filter[] - One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- outpost
Arn string - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- {[key: string]: string}
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- filters
Sequence[Get
Hosts Filter] - One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- outpost_
arn str - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Mapping[str, str]
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
- filters List<Property Map>
- One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
- outpost
Arn String - ARN of the AWS Outpost. Filters results client-side to only include hosts allocated on this Outpost.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Map<String>
- Key-value map of resource tags, each pair of which must exactly match a pair on the desired Dedicated Hosts.
getHosts Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- List of EC2 Dedicated Host identifiers.
- Region string
- Filters
List<Get
Hosts Filter> - Outpost
Arn string - Dictionary<string, string>
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- List of EC2 Dedicated Host identifiers.
- Region string
- Filters
[]Get
Hosts Filter - Outpost
Arn string - map[string]string
- id string
- The provider-assigned unique ID for this managed resource.
- ids list(string)
- List of EC2 Dedicated Host identifiers.
- region string
- filters list(object)
- outpost_
arn string - map(string)
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- List of EC2 Dedicated Host identifiers.
- region String
- filters
List<Get
Hosts Filter> - outpost
Arn String - Map<String,String>
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- List of EC2 Dedicated Host identifiers.
- region string
- filters
Get
Hosts Filter[] - outpost
Arn string - {[key: string]: string}
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- List of EC2 Dedicated Host identifiers.
- region str
- filters
Sequence[Get
Hosts Filter] - outpost_
arn str - Mapping[str, str]
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- List of EC2 Dedicated Host identifiers.
- region String
- filters List<Property Map>
- outpost
Arn String - Map<String>
Supporting Types
GetHostsFilter
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
Viewing docs for AWS v7.33.0
published on Monday, Jun 15, 2026 by Pulumi
published on Monday, Jun 15, 2026 by Pulumi