Retrieve information of an existing VPC Generation 2 compute subnet as a read only data source. For more information, about the IBM Cloud subnet, see attaching subnets to a routing table.
Note:
VPC infrastructure services are a regional specific based endpoint, by default targets to us-south. Please make sure to target right region in the provider block as shown in the provider.tf file, if VPC service is created in region other than us-south.
provider.tf
import * as pulumi from "@pulumi/pulumi";
import pulumi
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
return await Deployment.RunAsync(() =>
{
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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) {
}
}
{}
Example Usage
Example to retrieve the subnet information by using subnet name.
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const exampleIsVpc = new ibm.IsVpc("example", {name: "example-vpc"});
const exampleIsSubnet = new ibm.IsSubnet("example", {
name: "example-subnet",
vpc: exampleIsVpc.isVpcId,
zone: "us-south-1",
ipv4CidrBlock: "10.240.0.0/24",
});
const example = ibm.getIsSubnetOutput({
name: exampleIsSubnet.name,
});
import pulumi
import pulumi_ibm as ibm
example_is_vpc = ibm.IsVpc("example", name="example-vpc")
example_is_subnet = ibm.IsSubnet("example",
name="example-subnet",
vpc=example_is_vpc.is_vpc_id,
zone="us-south-1",
ipv4_cidr_block="10.240.0.0/24")
example = ibm.get_is_subnet_output(name=example_is_subnet.name)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleIsVpc, err := ibm.NewIsVpc(ctx, "example", &ibm.IsVpcArgs{
Name: pulumi.String("example-vpc"),
})
if err != nil {
return err
}
exampleIsSubnet, err := ibm.NewIsSubnet(ctx, "example", &ibm.IsSubnetArgs{
Name: pulumi.String("example-subnet"),
Vpc: exampleIsVpc.IsVpcId,
Zone: pulumi.String("us-south-1"),
Ipv4CidrBlock: pulumi.String("10.240.0.0/24"),
})
if err != nil {
return err
}
_ = ibm.LookupIsSubnetOutput(ctx, ibm.GetIsSubnetOutputArgs{
Name: exampleIsSubnet.Name,
}, nil)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var exampleIsVpc = new Ibm.IsVpc("example", new()
{
Name = "example-vpc",
});
var exampleIsSubnet = new Ibm.IsSubnet("example", new()
{
Name = "example-subnet",
Vpc = exampleIsVpc.IsVpcId,
Zone = "us-south-1",
Ipv4CidrBlock = "10.240.0.0/24",
});
var example = Ibm.GetIsSubnet.Invoke(new()
{
Name = exampleIsSubnet.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.IsVpc;
import com.pulumi.ibm.IsVpcArgs;
import com.pulumi.ibm.IsSubnet;
import com.pulumi.ibm.IsSubnetArgs;
import com.pulumi.ibm.IbmFunctions;
import com.pulumi.ibm.inputs.GetIsSubnetArgs;
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) {
var exampleIsVpc = new IsVpc("exampleIsVpc", IsVpcArgs.builder()
.name("example-vpc")
.build());
var exampleIsSubnet = new IsSubnet("exampleIsSubnet", IsSubnetArgs.builder()
.name("example-subnet")
.vpc(exampleIsVpc.isVpcId())
.zone("us-south-1")
.ipv4CidrBlock("10.240.0.0/24")
.build());
final var example = IbmFunctions.getIsSubnet(GetIsSubnetArgs.builder()
.name(exampleIsSubnet.name())
.build());
}
}
resources:
exampleIsVpc:
type: ibm:IsVpc
name: example
properties:
name: example-vpc
exampleIsSubnet:
type: ibm:IsSubnet
name: example
properties:
name: example-subnet
vpc: ${exampleIsVpc.isVpcId}
zone: us-south-1
ipv4CidrBlock: 10.240.0.0/24
variables:
example:
fn::invoke:
function: ibm:getIsSubnet
arguments:
name: ${exampleIsSubnet.name}
// Example to retrieve the subnet information by using subnet ID.
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const exampleIsVpc = new ibm.IsVpc("example", {name: "example-vpc"});
const exampleIsSubnet = new ibm.IsSubnet("example", {
name: "example-subnet",
vpc: exampleIsVpc.isVpcId,
zone: "us-south-1",
ipv4CidrBlock: "10.240.0.0/24",
});
const example = ibm.getIsSubnetOutput({
identifier: exampleIsSubnet.isSubnetId,
});
import pulumi
import pulumi_ibm as ibm
example_is_vpc = ibm.IsVpc("example", name="example-vpc")
example_is_subnet = ibm.IsSubnet("example",
name="example-subnet",
vpc=example_is_vpc.is_vpc_id,
zone="us-south-1",
ipv4_cidr_block="10.240.0.0/24")
example = ibm.get_is_subnet_output(identifier=example_is_subnet.is_subnet_id)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleIsVpc, err := ibm.NewIsVpc(ctx, "example", &ibm.IsVpcArgs{
Name: pulumi.String("example-vpc"),
})
if err != nil {
return err
}
exampleIsSubnet, err := ibm.NewIsSubnet(ctx, "example", &ibm.IsSubnetArgs{
Name: pulumi.String("example-subnet"),
Vpc: exampleIsVpc.IsVpcId,
Zone: pulumi.String("us-south-1"),
Ipv4CidrBlock: pulumi.String("10.240.0.0/24"),
})
if err != nil {
return err
}
_ = ibm.LookupIsSubnetOutput(ctx, ibm.GetIsSubnetOutputArgs{
Identifier: exampleIsSubnet.IsSubnetId,
}, nil)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var exampleIsVpc = new Ibm.IsVpc("example", new()
{
Name = "example-vpc",
});
var exampleIsSubnet = new Ibm.IsSubnet("example", new()
{
Name = "example-subnet",
Vpc = exampleIsVpc.IsVpcId,
Zone = "us-south-1",
Ipv4CidrBlock = "10.240.0.0/24",
});
var example = Ibm.GetIsSubnet.Invoke(new()
{
Identifier = exampleIsSubnet.IsSubnetId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.IsVpc;
import com.pulumi.ibm.IsVpcArgs;
import com.pulumi.ibm.IsSubnet;
import com.pulumi.ibm.IsSubnetArgs;
import com.pulumi.ibm.IbmFunctions;
import com.pulumi.ibm.inputs.GetIsSubnetArgs;
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) {
var exampleIsVpc = new IsVpc("exampleIsVpc", IsVpcArgs.builder()
.name("example-vpc")
.build());
var exampleIsSubnet = new IsSubnet("exampleIsSubnet", IsSubnetArgs.builder()
.name("example-subnet")
.vpc(exampleIsVpc.isVpcId())
.zone("us-south-1")
.ipv4CidrBlock("10.240.0.0/24")
.build());
final var example = IbmFunctions.getIsSubnet(GetIsSubnetArgs.builder()
.identifier(exampleIsSubnet.isSubnetId())
.build());
}
}
resources:
exampleIsVpc:
type: ibm:IsVpc
name: example
properties:
name: example-vpc
exampleIsSubnet:
type: ibm:IsSubnet
name: example
properties:
name: example-subnet
vpc: ${exampleIsVpc.isVpcId}
zone: us-south-1
ipv4CidrBlock: 10.240.0.0/24
variables:
example:
fn::invoke:
function: ibm:getIsSubnet
arguments:
identifier: ${exampleIsSubnet.isSubnetId}
Using getIsSubnet
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 getIsSubnet(args: GetIsSubnetArgs, opts?: InvokeOptions): Promise<GetIsSubnetResult>
function getIsSubnetOutput(args: GetIsSubnetOutputArgs, opts?: InvokeOptions): Output<GetIsSubnetResult>def get_is_subnet(id: Optional[str] = None,
identifier: Optional[str] = None,
name: Optional[str] = None,
vpc: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetIsSubnetResult
def get_is_subnet_output(id: Optional[pulumi.Input[str]] = None,
identifier: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
vpc: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetIsSubnetResult]func LookupIsSubnet(ctx *Context, args *LookupIsSubnetArgs, opts ...InvokeOption) (*LookupIsSubnetResult, error)
func LookupIsSubnetOutput(ctx *Context, args *LookupIsSubnetOutputArgs, opts ...InvokeOption) LookupIsSubnetResultOutput> Note: This function is named LookupIsSubnet in the Go SDK.
public static class GetIsSubnet
{
public static Task<GetIsSubnetResult> InvokeAsync(GetIsSubnetArgs args, InvokeOptions? opts = null)
public static Output<GetIsSubnetResult> Invoke(GetIsSubnetInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetIsSubnetResult> getIsSubnet(GetIsSubnetArgs args, InvokeOptions options)
public static Output<GetIsSubnetResult> getIsSubnet(GetIsSubnetArgs args, InvokeOptions options)
fn::invoke:
function: ibm:index/getIsSubnet:getIsSubnet
arguments:
# arguments dictionaryThe following arguments are supported:
- Id string
- (String) The unique identifier for this routing table.
- Identifier string
- The ID of the subnet,
nameandidentifierare mutually exclusive. - Name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - Vpc string
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
- Id string
- (String) The unique identifier for this routing table.
- Identifier string
- The ID of the subnet,
nameandidentifierare mutually exclusive. - Name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - Vpc string
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
- id String
- (String) The unique identifier for this routing table.
- identifier String
- The ID of the subnet,
nameandidentifierare mutually exclusive. - name String
- The name of the subnet,
nameandidentifierare mutually exclusive. - vpc String
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
- id string
- (String) The unique identifier for this routing table.
- identifier string
- The ID of the subnet,
nameandidentifierare mutually exclusive. - name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - vpc string
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
- id str
- (String) The unique identifier for this routing table.
- identifier str
- The ID of the subnet,
nameandidentifierare mutually exclusive. - name str
- The name of the subnet,
nameandidentifierare mutually exclusive. - vpc str
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
- id String
- (String) The unique identifier for this routing table.
- identifier String
- The ID of the subnet,
nameandidentifierare mutually exclusive. - name String
- The name of the subnet,
nameandidentifierare mutually exclusive. - vpc String
- Filters the collection to resources with a vpc property matching the specified identifier. Subnet
namemust be specified withvpcfilter.
getIsSubnet Result
The following output properties are available:
- List<string>
- (String) Access management tags associated for the instance.
- Available
Ipv4Address doubleCount - (Integer) The total number of available IPv4 addresses.
- Crn string
- (String) The crn for this routing table.
- Id string
- (String) The unique identifier for this routing table.
- Ipv4Cidr
Block string - (String) The IPv4 range of the subnet.
- Name string
- (String) The user-defined name for this routing table.
- Network
Acl string - (String) The ID of the network ACL for the subnet.
- Public
Gateway string - (String) The ID of the public gateway for the subnet.
- Resource
Controller stringUrl - Resource
Crn string - Resource
Group string - (String) The subnet resource group.
- Resource
Group stringName - Resource
Name string - Resource
Status string - Routing
Tables List<GetIs Subnet Routing Table> - (List) The routing table for this subnet.
- Status string
- (String) The status of the subnet.
- List<string>
- (String) Tags associated for the instance.
- Total
Ipv4Address doubleCount - (Integer) The total number of IPv4 addresses.
- Vpc string
- (String) The ID of the VPC that the subnet belongs to.
- Vpc
Name string - (String) The name of the VPC that the subnet belongs to.
- Zone string
- (String) The subnet zone name.
- Identifier string
- []string
- (String) Access management tags associated for the instance.
- Available
Ipv4Address float64Count - (Integer) The total number of available IPv4 addresses.
- Crn string
- (String) The crn for this routing table.
- Id string
- (String) The unique identifier for this routing table.
- Ipv4Cidr
Block string - (String) The IPv4 range of the subnet.
- Name string
- (String) The user-defined name for this routing table.
- Network
Acl string - (String) The ID of the network ACL for the subnet.
- Public
Gateway string - (String) The ID of the public gateway for the subnet.
- Resource
Controller stringUrl - Resource
Crn string - Resource
Group string - (String) The subnet resource group.
- Resource
Group stringName - Resource
Name string - Resource
Status string - Routing
Tables []GetIs Subnet Routing Table - (List) The routing table for this subnet.
- Status string
- (String) The status of the subnet.
- []string
- (String) Tags associated for the instance.
- Total
Ipv4Address float64Count - (Integer) The total number of IPv4 addresses.
- Vpc string
- (String) The ID of the VPC that the subnet belongs to.
- Vpc
Name string - (String) The name of the VPC that the subnet belongs to.
- Zone string
- (String) The subnet zone name.
- Identifier string
- List<String>
- (String) Access management tags associated for the instance.
- available
Ipv4Address DoubleCount - (Integer) The total number of available IPv4 addresses.
- crn String
- (String) The crn for this routing table.
- id String
- (String) The unique identifier for this routing table.
- ipv4Cidr
Block String - (String) The IPv4 range of the subnet.
- name String
- (String) The user-defined name for this routing table.
- network
Acl String - (String) The ID of the network ACL for the subnet.
- public
Gateway String - (String) The ID of the public gateway for the subnet.
- resource
Controller StringUrl - resource
Crn String - resource
Group String - (String) The subnet resource group.
- resource
Group StringName - resource
Name String - resource
Status String - routing
Tables List<GetIs Subnet Routing Table> - (List) The routing table for this subnet.
- status String
- (String) The status of the subnet.
- List<String>
- (String) Tags associated for the instance.
- total
Ipv4Address DoubleCount - (Integer) The total number of IPv4 addresses.
- vpc String
- (String) The ID of the VPC that the subnet belongs to.
- vpc
Name String - (String) The name of the VPC that the subnet belongs to.
- zone String
- (String) The subnet zone name.
- identifier String
- string[]
- (String) Access management tags associated for the instance.
- available
Ipv4Address numberCount - (Integer) The total number of available IPv4 addresses.
- crn string
- (String) The crn for this routing table.
- id string
- (String) The unique identifier for this routing table.
- ipv4Cidr
Block string - (String) The IPv4 range of the subnet.
- name string
- (String) The user-defined name for this routing table.
- network
Acl string - (String) The ID of the network ACL for the subnet.
- public
Gateway string - (String) The ID of the public gateway for the subnet.
- resource
Controller stringUrl - resource
Crn string - resource
Group string - (String) The subnet resource group.
- resource
Group stringName - resource
Name string - resource
Status string - routing
Tables GetIs Subnet Routing Table[] - (List) The routing table for this subnet.
- status string
- (String) The status of the subnet.
- string[]
- (String) Tags associated for the instance.
- total
Ipv4Address numberCount - (Integer) The total number of IPv4 addresses.
- vpc string
- (String) The ID of the VPC that the subnet belongs to.
- vpc
Name string - (String) The name of the VPC that the subnet belongs to.
- zone string
- (String) The subnet zone name.
- identifier string
- Sequence[str]
- (String) Access management tags associated for the instance.
- available_
ipv4_ floataddress_ count - (Integer) The total number of available IPv4 addresses.
- crn str
- (String) The crn for this routing table.
- id str
- (String) The unique identifier for this routing table.
- ipv4_
cidr_ strblock - (String) The IPv4 range of the subnet.
- name str
- (String) The user-defined name for this routing table.
- network_
acl str - (String) The ID of the network ACL for the subnet.
- public_
gateway str - (String) The ID of the public gateway for the subnet.
- resource_
controller_ strurl - resource_
crn str - resource_
group str - (String) The subnet resource group.
- resource_
group_ strname - resource_
name str - resource_
status str - routing_
tables Sequence[GetIs Subnet Routing Table] - (List) The routing table for this subnet.
- status str
- (String) The status of the subnet.
- Sequence[str]
- (String) Tags associated for the instance.
- total_
ipv4_ floataddress_ count - (Integer) The total number of IPv4 addresses.
- vpc str
- (String) The ID of the VPC that the subnet belongs to.
- vpc_
name str - (String) The name of the VPC that the subnet belongs to.
- zone str
- (String) The subnet zone name.
- identifier str
- List<String>
- (String) Access management tags associated for the instance.
- available
Ipv4Address NumberCount - (Integer) The total number of available IPv4 addresses.
- crn String
- (String) The crn for this routing table.
- id String
- (String) The unique identifier for this routing table.
- ipv4Cidr
Block String - (String) The IPv4 range of the subnet.
- name String
- (String) The user-defined name for this routing table.
- network
Acl String - (String) The ID of the network ACL for the subnet.
- public
Gateway String - (String) The ID of the public gateway for the subnet.
- resource
Controller StringUrl - resource
Crn String - resource
Group String - (String) The subnet resource group.
- resource
Group StringName - resource
Name String - resource
Status String - routing
Tables List<Property Map> - (List) The routing table for this subnet.
- status String
- (String) The status of the subnet.
- List<String>
- (String) Tags associated for the instance.
- total
Ipv4Address NumberCount - (Integer) The total number of IPv4 addresses.
- vpc String
- (String) The ID of the VPC that the subnet belongs to.
- vpc
Name String - (String) The name of the VPC that the subnet belongs to.
- zone String
- (String) The subnet zone name.
- identifier String
Supporting Types
GetIsSubnetRoutingTable
- Crn string
- (String) The crn for this routing table.
- Deleteds
List<Get
Is Subnet Routing Table Deleted> - (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- Href string
- (String) The URL for this routing table.
- Id string
- (String) The unique identifier for this routing table.
- Name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - Resource
Type string - (String) The type of resource referenced.
- Crn string
- (String) The crn for this routing table.
- Deleteds
[]Get
Is Subnet Routing Table Deleted - (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- Href string
- (String) The URL for this routing table.
- Id string
- (String) The unique identifier for this routing table.
- Name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - Resource
Type string - (String) The type of resource referenced.
- crn String
- (String) The crn for this routing table.
- deleteds
List<Get
Is Subnet Routing Table Deleted> - (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- href String
- (String) The URL for this routing table.
- id String
- (String) The unique identifier for this routing table.
- name String
- The name of the subnet,
nameandidentifierare mutually exclusive. - resource
Type String - (String) The type of resource referenced.
- crn string
- (String) The crn for this routing table.
- deleteds
Get
Is Subnet Routing Table Deleted[] - (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- href string
- (String) The URL for this routing table.
- id string
- (String) The unique identifier for this routing table.
- name string
- The name of the subnet,
nameandidentifierare mutually exclusive. - resource
Type string - (String) The type of resource referenced.
- crn str
- (String) The crn for this routing table.
- deleteds
Sequence[Get
Is Subnet Routing Table Deleted] - (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- href str
- (String) The URL for this routing table.
- id str
- (String) The unique identifier for this routing table.
- name str
- The name of the subnet,
nameandidentifierare mutually exclusive. - resource_
type str - (String) The type of resource referenced.
- crn String
- (String) The crn for this routing table.
- deleteds List<Property Map>
- (List) If present, this property indicates the referenced resource has been deleted and provides some supplementary information.
- href String
- (String) The URL for this routing table.
- id String
- (String) The unique identifier for this routing table.
- name String
- The name of the subnet,
nameandidentifierare mutually exclusive. - resource
Type String - (String) The type of resource referenced.
GetIsSubnetRoutingTableDeleted
- More
Info string - (String) Link to documentation about deleted resources.
- More
Info string - (String) Link to documentation about deleted resources.
- more
Info String - (String) Link to documentation about deleted resources.
- more
Info string - (String) Link to documentation about deleted resources.
- more_
info str - (String) Link to documentation about deleted resources.
- more
Info String - (String) Link to documentation about deleted resources.
Package Details
- Repository
- ibm ibm-cloud/terraform-provider-ibm
- License
- Notes
- This Pulumi package is based on the
ibmTerraform Provider.
