AWS v7.10.0 published on Friday, Oct 24, 2025 by Pulumi
aws.ec2.getSubnets
This resource can be useful for getting back a set of subnet IDs.
Using getSubnets
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 getSubnets(args: GetSubnetsArgs, opts?: InvokeOptions): Promise<GetSubnetsResult>
function getSubnetsOutput(args: GetSubnetsOutputArgs, opts?: InvokeOptions): Output<GetSubnetsResult>def get_subnets(filters: Optional[Sequence[GetSubnetsFilter]] = None,
                region: Optional[str] = None,
                tags: Optional[Mapping[str, str]] = None,
                opts: Optional[InvokeOptions] = None) -> GetSubnetsResult
def get_subnets_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSubnetsFilterArgs]]]] = None,
                region: Optional[pulumi.Input[str]] = None,
                tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetSubnetsResult]func GetSubnets(ctx *Context, args *GetSubnetsArgs, opts ...InvokeOption) (*GetSubnetsResult, error)
func GetSubnetsOutput(ctx *Context, args *GetSubnetsOutputArgs, opts ...InvokeOption) GetSubnetsResultOutput> Note: This function is named GetSubnets in the Go SDK.
public static class GetSubnets 
{
    public static Task<GetSubnetsResult> InvokeAsync(GetSubnetsArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetsResult> Invoke(GetSubnetsInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetSubnetsResult> getSubnets(GetSubnetsArgs args, InvokeOptions options)
public static Output<GetSubnetsResult> getSubnets(GetSubnetsArgs args, InvokeOptions options)
fn::invoke:
  function: aws:ec2/getSubnets:getSubnets
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Filters
List<Get
Subnets Filter>  - Custom filter block as described below.
 - Region string
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - Dictionary<string, string>
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
- Filters
[]Get
Subnets Filter  - Custom filter block as described below.
 - Region string
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - map[string]string
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
- filters
List<Get
Subnets Filter>  - Custom filter block as described below.
 - region String
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - Map<String,String>
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
- filters
Get
Subnets Filter[]  - Custom filter block as described below.
 - region string
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - {[key: string]: string}
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
- filters
Sequence[Get
Subnets Filter]  - Custom filter block as described below.
 - region str
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - Mapping[str, str]
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
- filters List<Property Map>
 - Custom filter block as described below.
 - region String
 - Region where this resource will be managed. Defaults to the Region set in the provider configuration.
 - Map<String>
 - Map of tags, each pair of which must exactly match a pair on the desired subnets.
 
getSubnets Result
The following output properties are available:
- Id string
 - The provider-assigned unique ID for this managed resource.
 - Ids List<string>
 - List of all the subnet ids found.
 - Region string
 - Dictionary<string, string>
 - Filters
List<Get
Subnets Filter>  
- Id string
 - The provider-assigned unique ID for this managed resource.
 - Ids []string
 - List of all the subnet ids found.
 - Region string
 - map[string]string
 - Filters
[]Get
Subnets Filter  
- id String
 - The provider-assigned unique ID for this managed resource.
 - ids List<String>
 - List of all the subnet ids found.
 - region String
 - Map<String,String>
 - filters
List<Get
Subnets Filter>  
- id string
 - The provider-assigned unique ID for this managed resource.
 - ids string[]
 - List of all the subnet ids found.
 - region string
 - {[key: string]: string}
 - filters
Get
Subnets Filter[]  
- id str
 - The provider-assigned unique ID for this managed resource.
 - ids Sequence[str]
 - List of all the subnet ids found.
 - region str
 - Mapping[str, str]
 - filters
Sequence[Get
Subnets Filter]  
- id String
 - The provider-assigned unique ID for this managed resource.
 - ids List<String>
 - List of all the subnet ids found.
 - region String
 - Map<String>
 - filters List<Property Map>
 
Supporting Types
GetSubnetsFilter  
- Name string
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - Values List<string>
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
- Name string
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - Values []string
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
- name String
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - values List<String>
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
- name string
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - values string[]
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
- name str
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - values Sequence[str]
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
- name String
 - Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against tag 
Name, use: - values List<String>
 - Set of values that are accepted for the given field. Subnet IDs will be selected if any one of the given values match.
 
Package Details
- Repository
 - AWS Classic pulumi/pulumi-aws
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
awsTerraform Provider. 
