ucloud.Subnet
Explore with Pulumi AI
Provides a Subnet resource under VPC resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ucloud from "@pulumi/ucloud";
const _default = new ucloud.Vpc("default", {
tag: "tf-example",
cidrBlocks: ["192.168.0.0/16"],
});
const example = new ucloud.Subnet("example", {
tag: "tf-example",
cidrBlock: "192.168.1.0/24",
vpcId: _default.vpcId,
});
import pulumi
import pulumi_ucloud as ucloud
default = ucloud.Vpc("default",
tag="tf-example",
cidr_blocks=["192.168.0.0/16"])
example = ucloud.Subnet("example",
tag="tf-example",
cidr_block="192.168.1.0/24",
vpc_id=default.vpc_id)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := ucloud.NewVpc(ctx, "default", &ucloud.VpcArgs{
Tag: pulumi.String("tf-example"),
CidrBlocks: pulumi.StringArray{
pulumi.String("192.168.0.0/16"),
},
})
if err != nil {
return err
}
_, err = ucloud.NewSubnet(ctx, "example", &ucloud.SubnetArgs{
Tag: pulumi.String("tf-example"),
CidrBlock: pulumi.String("192.168.1.0/24"),
VpcId: _default.VpcId,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ucloud = Pulumi.Ucloud;
return await Deployment.RunAsync(() =>
{
var @default = new Ucloud.Vpc("default", new()
{
Tag = "tf-example",
CidrBlocks = new[]
{
"192.168.0.0/16",
},
});
var example = new Ucloud.Subnet("example", new()
{
Tag = "tf-example",
CidrBlock = "192.168.1.0/24",
VpcId = @default.VpcId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ucloud.Vpc;
import com.pulumi.ucloud.VpcArgs;
import com.pulumi.ucloud.Subnet;
import com.pulumi.ucloud.SubnetArgs;
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 default_ = new Vpc("default", VpcArgs.builder()
.tag("tf-example")
.cidrBlocks("192.168.0.0/16")
.build());
var example = new Subnet("example", SubnetArgs.builder()
.tag("tf-example")
.cidrBlock("192.168.1.0/24")
.vpcId(default_.vpcId())
.build());
}
}
resources:
default:
type: ucloud:Vpc
properties:
tag: tf-example
# vpc network
cidrBlocks:
- 192.168.0.0/16
example:
type: ucloud:Subnet
properties:
tag: tf-example
# subnet's network must be contained by vpc network
# # and a subnet must have least 8 ip addresses in it (netmask < 30).
cidrBlock: 192.168.1.0/24
vpcId: ${default.vpcId}
Create Subnet Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Subnet(name: string, args: SubnetArgs, opts?: CustomResourceOptions);
@overload
def Subnet(resource_name: str,
args: SubnetArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Subnet(resource_name: str,
opts: Optional[ResourceOptions] = None,
cidr_block: Optional[str] = None,
vpc_id: Optional[str] = None,
name: Optional[str] = None,
remark: Optional[str] = None,
subnet_id: Optional[str] = None,
tag: Optional[str] = None)
func NewSubnet(ctx *Context, name string, args SubnetArgs, opts ...ResourceOption) (*Subnet, error)
public Subnet(string name, SubnetArgs args, CustomResourceOptions? opts = null)
public Subnet(String name, SubnetArgs args)
public Subnet(String name, SubnetArgs args, CustomResourceOptions options)
type: ucloud:Subnet
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var subnetResource = new Ucloud.Subnet("subnetResource", new()
{
CidrBlock = "string",
VpcId = "string",
Name = "string",
Remark = "string",
SubnetId = "string",
Tag = "string",
});
example, err := ucloud.NewSubnet(ctx, "subnetResource", &ucloud.SubnetArgs{
CidrBlock: pulumi.String("string"),
VpcId: pulumi.String("string"),
Name: pulumi.String("string"),
Remark: pulumi.String("string"),
SubnetId: pulumi.String("string"),
Tag: pulumi.String("string"),
})
var subnetResource = new Subnet("subnetResource", SubnetArgs.builder()
.cidrBlock("string")
.vpcId("string")
.name("string")
.remark("string")
.subnetId("string")
.tag("string")
.build());
subnet_resource = ucloud.Subnet("subnetResource",
cidr_block="string",
vpc_id="string",
name="string",
remark="string",
subnet_id="string",
tag="string")
const subnetResource = new ucloud.Subnet("subnetResource", {
cidrBlock: "string",
vpcId: "string",
name: "string",
remark: "string",
subnetId: "string",
tag: "string",
});
type: ucloud:Subnet
properties:
cidrBlock: string
name: string
remark: string
subnetId: string
tag: string
vpcId: string
Subnet Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Subnet resource accepts the following input properties:
- Cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - Vpc
Id string - The id of the VPC that the desired subnet belongs to.
- Name string
- Remark string
- The remarks of the subnet. (Default:
""
). - Subnet
Id string - The ID of the resource subnet.
- Tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- Cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - Vpc
Id string - The id of the VPC that the desired subnet belongs to.
- Name string
- Remark string
- The remarks of the subnet. (Default:
""
). - Subnet
Id string - The ID of the resource subnet.
- Tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- cidr
Block String - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - vpc
Id String - The id of the VPC that the desired subnet belongs to.
- name String
- remark String
- The remarks of the subnet. (Default:
""
). - subnet
Id String - The ID of the resource subnet.
- tag String
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - vpc
Id string - The id of the VPC that the desired subnet belongs to.
- name string
- remark string
- The remarks of the subnet. (Default:
""
). - subnet
Id string - The ID of the resource subnet.
- tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- cidr_
block str - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - vpc_
id str - The id of the VPC that the desired subnet belongs to.
- name str
- remark str
- The remarks of the subnet. (Default:
""
). - subnet_
id str - The ID of the resource subnet.
- tag str
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- cidr
Block String - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - vpc
Id String - The id of the VPC that the desired subnet belongs to.
- name String
- remark String
- The remarks of the subnet. (Default:
""
). - subnet
Id String - The ID of the resource subnet.
- tag String
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
Outputs
All input properties are implicitly available as output properties. Additionally, the Subnet resource produces the following output properties:
- Create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- Id string
- The provider-assigned unique ID for this managed resource.
- create
Time String - The time of creation of subnet, formatted in RFC3339 time string.
- id String
- The provider-assigned unique ID for this managed resource.
- create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- id string
- The provider-assigned unique ID for this managed resource.
- create_
time str - The time of creation of subnet, formatted in RFC3339 time string.
- id str
- The provider-assigned unique ID for this managed resource.
- create
Time String - The time of creation of subnet, formatted in RFC3339 time string.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Subnet Resource
Get an existing Subnet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SubnetState, opts?: CustomResourceOptions): Subnet
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cidr_block: Optional[str] = None,
create_time: Optional[str] = None,
name: Optional[str] = None,
remark: Optional[str] = None,
subnet_id: Optional[str] = None,
tag: Optional[str] = None,
vpc_id: Optional[str] = None) -> Subnet
func GetSubnet(ctx *Context, name string, id IDInput, state *SubnetState, opts ...ResourceOption) (*Subnet, error)
public static Subnet Get(string name, Input<string> id, SubnetState? state, CustomResourceOptions? opts = null)
public static Subnet get(String name, Output<String> id, SubnetState state, CustomResourceOptions options)
resources: _: type: ucloud:Subnet get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - Create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- Name string
- Remark string
- The remarks of the subnet. (Default:
""
). - Subnet
Id string - The ID of the resource subnet.
- Tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - Vpc
Id string - The id of the VPC that the desired subnet belongs to.
- Cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - Create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- Name string
- Remark string
- The remarks of the subnet. (Default:
""
). - Subnet
Id string - The ID of the resource subnet.
- Tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - Vpc
Id string - The id of the VPC that the desired subnet belongs to.
- cidr
Block String - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - create
Time String - The time of creation of subnet, formatted in RFC3339 time string.
- name String
- remark String
- The remarks of the subnet. (Default:
""
). - subnet
Id String - The ID of the resource subnet.
- tag String
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - vpc
Id String - The id of the VPC that the desired subnet belongs to.
- cidr
Block string - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - create
Time string - The time of creation of subnet, formatted in RFC3339 time string.
- name string
- remark string
- The remarks of the subnet. (Default:
""
). - subnet
Id string - The ID of the resource subnet.
- tag string
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - vpc
Id string - The id of the VPC that the desired subnet belongs to.
- cidr_
block str - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - create_
time str - The time of creation of subnet, formatted in RFC3339 time string.
- name str
- remark str
- The remarks of the subnet. (Default:
""
). - subnet_
id str - The ID of the resource subnet.
- tag str
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - vpc_
id str - The id of the VPC that the desired subnet belongs to.
- cidr
Block String - The cidr block of the desired subnet, format in "0.0.0.0/0", such as:
192.168.0.0/24
. - create
Time String - The time of creation of subnet, formatted in RFC3339 time string.
- name String
- remark String
- The remarks of the subnet. (Default:
""
). - subnet
Id String - The ID of the resource subnet.
- tag String
- A tag assigned to subnet, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
). - vpc
Id String - The id of the VPC that the desired subnet belongs to.
Import
Subnet can be imported using the id
, e.g.
$ pulumi import ucloud:index/subnet:Subnet example subnet-abc123456
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- ucloud ucloud/terraform-provider-ucloud
- License
- Notes
- This Pulumi package is based on the
ucloud
Terraform Provider.