Subnetwork Args
A VPC network is a virtual version of the traditional physical networks that exist within and between physical data centers. A VPC network provides connectivity for your Compute Engine virtual machine (VM) instances, Container Engine containers, App Engine Flex services, and other network-related resources. Each GCP project contains one or more VPC networks. Each VPC network is a global entity spanning all GCP regions. This global VPC network allows VM instances and other resources to communicate with each other via internal, private IP addresses. Each VPC network is subdivided into subnets, and each subnet is contained within a single region. You can have more than one subnet in a region for a given VPC network. Each subnet has a contiguous private RFC1918 IP space. You create instances, containers, and the like in these subnets. When you create an instance, you must create it in a subnet, and the instance draws its internal IP address from that subnet. Virtual machine (VM) instances in a VPC network can communicate with instances in all other subnets of the same VPC network, regardless of region, using their RFC1918 private IP addresses. You can isolate portions of the network, even entire subnets, using firewall rules. To get more information about Subnetwork, see:
Example Usage
Subnetwork Basic
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
import com.pulumi.gcp.compute.inputs.SubnetworkSecondaryIpRangeArgs;
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 custom_test = new Network("custom-test", NetworkArgs.builder()
.autoCreateSubnetworks(false)
.build());
var network_with_private_secondary_ip_ranges = new Subnetwork("network-with-private-secondary-ip-ranges", SubnetworkArgs.builder()
.ipCidrRange("10.2.0.0/16")
.region("us-central1")
.network(custom_test.id())
.secondaryIpRanges(SubnetworkSecondaryIpRangeArgs.builder()
.rangeName("tf-test-secondary-range-update1")
.ipCidrRange("192.168.10.0/24")
.build())
.build());
}
}
Subnetwork Logging Config
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
import com.pulumi.gcp.compute.inputs.SubnetworkLogConfigArgs;
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 custom_test = new Network("custom-test", NetworkArgs.builder()
.autoCreateSubnetworks(false)
.build());
var subnet_with_logging = new Subnetwork("subnet-with-logging", SubnetworkArgs.builder()
.ipCidrRange("10.2.0.0/16")
.region("us-central1")
.network(custom_test.id())
.logConfig(SubnetworkLogConfigArgs.builder()
.aggregationInterval("INTERVAL_10_MIN")
.flowSampling(0.5)
.metadata("INCLUDE_ALL_METADATA")
.build())
.build());
}
}
Subnetwork Internal L7lb
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
import com.pulumi.resources.CustomResourceOptions;
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 custom_test = new Network("custom-test", NetworkArgs.builder()
.autoCreateSubnetworks(false)
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
var network_for_l7lb = new Subnetwork("network-for-l7lb", SubnetworkArgs.builder()
.ipCidrRange("10.0.0.0/22")
.region("us-central1")
.purpose("REGIONAL_MANAGED_PROXY")
.role("ACTIVE")
.network(custom_test.id())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
}
}
Subnetwork Ipv6
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
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 custom_test = new Network("custom-test", NetworkArgs.builder()
.autoCreateSubnetworks(false)
.build());
var subnetwork_ipv6 = new Subnetwork("subnetwork-ipv6", SubnetworkArgs.builder()
.ipCidrRange("10.0.0.0/22")
.region("us-west2")
.stackType("IPV4_IPV6")
.ipv6AccessType("EXTERNAL")
.network(custom_test.id())
.build());
}
}
Subnetwork Internal Ipv6
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
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 custom_test = new Network("custom-test", NetworkArgs.builder()
.autoCreateSubnetworks(false)
.enableUlaInternalIpv6(true)
.build());
var subnetwork_internal_ipv6 = new Subnetwork("subnetwork-internal-ipv6", SubnetworkArgs.builder()
.ipCidrRange("10.0.0.0/22")
.region("us-west2")
.stackType("IPV4_IPV6")
.ipv6AccessType("INTERNAL")
.network(custom_test.id())
.build());
}
}
Import
Subnetwork can be imported using any of these accepted formats
$ pulumi import gcp:compute/subnetwork:Subnetwork default projects/{{project}}/regions/{{region}}/subnetworks/{{name}}
$ pulumi import gcp:compute/subnetwork:Subnetwork default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/subnetwork:Subnetwork default {{region}}/{{name}}
$ pulumi import gcp:compute/subnetwork:Subnetwork default {{name}}
Constructors
Properties
An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time.
The range of internal addresses that are owned by this subnetwork. Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only IPv4 is supported.
The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack. If the ipv6_type is EXTERNAL then this subnet cannot enable direct path. Possible values are: EXTERNAL
, INTERNAL
.
This field denotes the VPC flow logging options for this subnetwork. If logging is enabled, logs are exported to Cloud Logging. Flow logging isn't supported if the subnet purpose
field is set to subnetwork is REGIONAL_MANAGED_PROXY
or GLOBAL_MANAGED_PROXY
. Structure is documented below.
The name of the resource, provided by the client when initially creating the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z?
which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
When enabled, VMs in this subnetwork without external IP addresses can access Google APIs and services by using Private Google Access.
The private IPv6 google access type for the VMs in this subnet.
The purpose of the resource. This field can be either PRIVATE_RFC_1918
, REGIONAL_MANAGED_PROXY
, GLOBAL_MANAGED_PROXY
, or PRIVATE_SERVICE_CONNECT
. A subnet with purpose set to REGIONAL_MANAGED_PROXY
is a user-created subnetwork that is reserved for regional Envoy-based load balancers. A subnetwork in a given region with purpose set to GLOBAL_MANAGED_PROXY
is a proxy-only subnet and is shared between all the cross-regional Envoy-based load balancers. A subnetwork with purpose set to PRIVATE_SERVICE_CONNECT
reserves the subnet for hosting a Private Service Connect published service. Note that REGIONAL_MANAGED_PROXY
is the preferred setting for all regional Envoy load balancers. If unspecified, the purpose defaults to PRIVATE_RFC_1918
.
The role of subnetwork. Currently, this field is only used when purpose
is REGIONAL_MANAGED_PROXY
. The value can be set to ACTIVE
or BACKUP
. An ACTIVE
subnetwork is one that is currently being used for Envoy-based load balancers in a region. A BACKUP
subnetwork is one that is ready to be promoted to ACTIVE
or is currently draining. Possible values are: ACTIVE
, BACKUP
.
An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange of the subnetwork. The alias IPs may belong to either primary or secondary ranges. Structure is documented below.