title: "getSubnet" title_tag: "huaweicloud.Vpc.getSubnet" meta_desc: "Documentation for the huaweicloud.Vpc.getSubnet function with examples, input properties, output properties, and supporting types." layout: api no_edit_this_page: true
Provides details about a specific VPC subnet.
This resource can prove useful when a module accepts a subnet id as an input variable and needs to, for example, determine the id of the VPC that the subnet belongs to.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
-
dns_list
- The IP address list of DNS servers on the subnet. -
dhcp_enable
- Whether the DHCP is enabled. -
description
- The description of the subnet. -
ipv4_subnet_id
- The ID of the IPv4 subnet (Native OpenStack API). -
ipv6_enable
- Whether the IPv6 is enabled. -
ipv6_subnet_id
- The ID of the IPv6 subnet (Native OpenStack API). -
ipv6_cidr
- The IPv6 subnet CIDR block. -
ipv6_gateway
- The IPv6 subnet gateway.
using System.Collections.Generic;
using Pulumi;
using Huaweicloud = Pulumi.Huaweicloud;
return await Deployment.RunAsync(() =>
{
var subnet = Huaweicloud.Vpc.GetSubnet.Invoke(new()
{
Id = @var.Subnet_id,
});
return new Dictionary<string, object?>
{
["subnetVpcId"] = subnet.Apply(getSubnetResult => getSubnetResult.VpcId),
};
});
package main
import (
"github.com/huaweicloud/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
"github.com/pulumi/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
subnet, err := Vpc.GetSubnet(ctx, &vpc.GetSubnetArgs{
Id: pulumi.StringRef(_var.Subnet_id),
}, nil)
if err != nil {
return err
}
ctx.Export("subnetVpcId", subnet.VpcId)
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.huaweicloud.Vpc.VpcFunctions;
import com.pulumi.huaweicloud.Vpc.inputs.GetSubnetArgs;
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 subnet = VpcFunctions.getSubnet(GetSubnetArgs.builder()
.id(var_.subnet_id())
.build());
ctx.export("subnetVpcId", subnet.applyValue(getSubnetResult -> getSubnetResult.vpcId()));
}
}
import pulumi
import pulumi_huaweicloud as huaweicloud
subnet = huaweicloud.Vpc.get_subnet(id=var["subnet_id"])
pulumi.export("subnetVpcId", subnet.vpc_id)
import * as pulumi from "@pulumi/pulumi";
import * as huaweicloud from "@pulumi/huaweicloud";
const subnet = huaweicloud.Vpc.getSubnet({
id: _var.subnet_id,
});
export const subnetVpcId = subnet.then(subnet => subnet.vpcId);
variables:
subnet:
Fn::Invoke:
Function: huaweicloud:Vpc:getSubnet
Arguments:
id: ${var.subnet_id}
outputs:
subnetVpcId: ${subnet.vpcId}
Using getSubnet {#using}
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 getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>
def get_subnet(availability_zone: Optional[str] = None,
cidr: Optional[str] = None,
gateway_ip: Optional[str] = None,
id: Optional[str] = None,
name: Optional[str] = None,
primary_dns: Optional[str] = None,
region: Optional[str] = None,
secondary_dns: Optional[str] = None,
status: Optional[str] = None,
vpc_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSubnetResult
def get_subnet_output(availability_zone: Optional[pulumi.Input[str]] = None,
cidr: Optional[pulumi.Input[str]] = None,
gateway_ip: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
primary_dns: Optional[pulumi.Input[str]] = None,
region: Optional[pulumi.Input[str]] = None,
secondary_dns: Optional[pulumi.Input[str]] = None,
status: Optional[pulumi.Input[str]] = None,
vpc_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]
func GetSubnet(ctx *Context, args *GetSubnetArgs, opts ...InvokeOption) (*GetSubnetResult, error)
func GetSubnetOutput(ctx *Context, args *GetSubnetOutputArgs, opts ...InvokeOption) GetSubnetResultOutput
> Note: This function is named GetSubnet
in the Go SDK.
public static class GetSubnet
{
public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
Function: huaweicloud:Vpc/getSubnet:getSubnet
Arguments:
# Arguments dictionary
The following arguments are supported:
-
Availability
Zone string Specifies the availability zone (AZ) to which the subnet should belong.
- Cidr string
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
Gateway
Ip string Specifies the subnet gateway address of specific subnet.
- Id string
- Specifies a resource ID in UUID format.
- Name string
Specifies the name of the specific subnet to retrieve.
-
Primary
Dns string Specifies the IP address of DNS server 1 on the specific subnet.
- Region string
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
Secondary
Dns string Specifies the IP address of DNS server 2 on the specific subnet.
- Status string
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
Vpc
Id string Specifies the id of the VPC that the desired subnet belongs to.
-
Availability
Zone string Specifies the availability zone (AZ) to which the subnet should belong.
- Cidr string
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
Gateway
Ip string Specifies the subnet gateway address of specific subnet.
- Id string
- Specifies a resource ID in UUID format.
- Name string
Specifies the name of the specific subnet to retrieve.
-
Primary
Dns string Specifies the IP address of DNS server 1 on the specific subnet.
- Region string
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
Secondary
Dns string Specifies the IP address of DNS server 2 on the specific subnet.
- Status string
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
Vpc
Id string Specifies the id of the VPC that the desired subnet belongs to.
-
availability
Zone String Specifies the availability zone (AZ) to which the subnet should belong.
- cidr String
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
gateway
Ip String Specifies the subnet gateway address of specific subnet.
- id String
- Specifies a resource ID in UUID format.
- name String
Specifies the name of the specific subnet to retrieve.
-
primary
Dns String Specifies the IP address of DNS server 1 on the specific subnet.
- region String
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
secondary
Dns String Specifies the IP address of DNS server 2 on the specific subnet.
- status String
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
vpc
Id String Specifies the id of the VPC that the desired subnet belongs to.
-
availability
Zone string Specifies the availability zone (AZ) to which the subnet should belong.
- cidr string
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
gateway
Ip string Specifies the subnet gateway address of specific subnet.
- id string
- Specifies a resource ID in UUID format.
- name string
Specifies the name of the specific subnet to retrieve.
-
primary
Dns string Specifies the IP address of DNS server 1 on the specific subnet.
- region string
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
secondary
Dns string Specifies the IP address of DNS server 2 on the specific subnet.
- status string
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
vpc
Id string Specifies the id of the VPC that the desired subnet belongs to.
-
availability_
zone str Specifies the availability zone (AZ) to which the subnet should belong.
- cidr str
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
gateway_
ip str Specifies the subnet gateway address of specific subnet.
- id str
- Specifies a resource ID in UUID format.
- name str
Specifies the name of the specific subnet to retrieve.
-
primary_
dns str Specifies the IP address of DNS server 1 on the specific subnet.
- region str
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
secondary_
dns str Specifies the IP address of DNS server 2 on the specific subnet.
- status str
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
vpc_
id str Specifies the id of the VPC that the desired subnet belongs to.
-
availability
Zone String Specifies the availability zone (AZ) to which the subnet should belong.
- cidr String
Specifies the network segment of specific subnet to retrieve. The value must be in CIDR format.
-
gateway
Ip String Specifies the subnet gateway address of specific subnet.
- id String
- Specifies a resource ID in UUID format.
- name String
Specifies the name of the specific subnet to retrieve.
-
primary
Dns String Specifies the IP address of DNS server 1 on the specific subnet.
- region String
Specifies the region in which to obtain the subnet. If omitted, the provider-level region will be used.
-
secondary
Dns String Specifies the IP address of DNS server 2 on the specific subnet.
- status String
Specifies the value can be ACTIVE, DOWN, UNKNOWN, or ERROR.
-
vpc
Id String Specifies the id of the VPC that the desired subnet belongs to.
getSubnet Result {#result}
The following output properties are available:
-
Availability
Zone string - Cidr string
- Description string
-
Dhcp
Enable bool -
Dns
Lists List<string> -
Gateway
Ip string - Id string
-
Ipv4Subnet
Id string - Ipv6Cidr string
- Ipv6Enable bool
- Ipv6Gateway string
-
Ipv6Subnet
Id string - Name string
-
Primary
Dns string - Region string
-
Secondary
Dns string - Status string
-
Subnet
Id string -
Vpc
Id string
-
Availability
Zone string - Cidr string
- Description string
-
Dhcp
Enable bool -
Dns
Lists []string -
Gateway
Ip string - Id string
-
Ipv4Subnet
Id string - Ipv6Cidr string
- Ipv6Enable bool
- Ipv6Gateway string
-
Ipv6Subnet
Id string - Name string
-
Primary
Dns string - Region string
-
Secondary
Dns string - Status string
-
Subnet
Id string -
Vpc
Id string
-
availability
Zone String - cidr String
- description String
-
dhcp
Enable Boolean -
dns
Lists List<String> -
gateway
Ip String - id String
-
ipv4Subnet
Id String - ipv6Cidr String
- ipv6Enable Boolean
- ipv6Gateway String
-
ipv6Subnet
Id String - name String
-
primary
Dns String - region String
-
secondary
Dns String - status String
-
subnet
Id String -
vpc
Id String
-
availability
Zone string - cidr string
- description string
-
dhcp
Enable boolean -
dns
Lists string[] -
gateway
Ip string - id string
-
ipv4Subnet
Id string - ipv6Cidr string
- ipv6Enable boolean
- ipv6Gateway string
-
ipv6Subnet
Id string - name string
-
primary
Dns string - region string
-
secondary
Dns string - status string
-
subnet
Id string -
vpc
Id string
-
availability_
zone str - cidr str
- description str
-
dhcp_
enable bool -
dns_
lists Sequence[str] -
gateway_
ip str - id str
-
ipv4_
subnet_ strid -
ipv6_
cidr str -
ipv6_
enable bool -
ipv6_
gateway str -
ipv6_
subnet_ strid - name str
-
primary_
dns str - region str
-
secondary_
dns str - status str
-
subnet_
id str -
vpc_
id str
-
availability
Zone String - cidr String
- description String
-
dhcp
Enable Boolean -
dns
Lists List<String> -
gateway
Ip String - id String
-
ipv4Subnet
Id String - ipv6Cidr String
- ipv6Enable Boolean
- ipv6Gateway String
-
ipv6Subnet
Id String - name String
-
primary
Dns String - region String
-
secondary
Dns String - status String
-
subnet
Id String -
vpc
Id String
Package Details
- Repository
- https://github.com/huaweicloud/pulumi-huaweicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
huaweicloud
Terraform Provider.