NAME

gcloud compute networks subnets create - define a subnet for a network in custom subnet mode

SYNOPSIS

gcloud compute networks subnets create NAME --network=NETWORK --range=RANGE [--description=DESCRIPTION] [--enable-flow-logs] [--enable-private-ip-google-access] [--ipv6-access-type=IPV6_ACCESS_TYPE] [--logging-aggregation-interval=LOGGING_AGGREGATION_INTERVAL] [--logging-filter-expr=LOGGING_FILTER_EXPR] [--logging-flow-sampling=LOGGING_FLOW_SAMPLING] [--logging-metadata=LOGGING_METADATA] [--logging-metadata-fields=[METADATA_FIELD,...]] [--private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPE] [--purpose=PURPOSE] [--region=REGION] [--role=ROLE] [--secondary-range=PROPERTY=VALUE,[...]] [--stack-type=STACK_TYPE] [GCLOUD_WIDE_FLAG ...]

DESCRIPTION

gcloud compute networks subnets create define a subnetwork for a network in custom subnet mode. Subnets must be uniquely named per region.

EXAMPLES

To create the subnetwork subnet-1 with address range 10.10.0.0/24 in the network network-0, run:

$ gcloud compute networks subnets create subnet-1 \ --network=network-0 --range=10.10.0.0/24 --region=us-central1

POSITIONAL ARGUMENTS

NAME

Name of the subnetwork to create.

REQUIRED FLAGS

--network=NETWORK

The network to which the subnetwork belongs.

--range=RANGE

The IP space allocated to this subnetwork in CIDR format.

OPTIONAL FLAGS

--description=DESCRIPTION

An optional description of this subnetwork.

--enable-flow-logs

Enable/disable VPC Flow Logs for this subnet. More information for VPC Flow Logs can be found at https://cloud.google.com/vpc/docs/using-flow-logs.

--enable-private-ip-google-access

Enable/disable access to Google Cloud APIs from this subnet for instances without a public ip address.

--ipv6-access-type=IPV6_ACCESS_TYPE

IPv6 access type can be specified only when the subnet is created, or when the subnet is first updated to have a stack type of IPV4_IPV6. Once set, the access type is immutable. IPV6_ACCESS_TYPE must be one of:

EXTERNAL

VMs in this subnet can have external IPv6.

INTERNAL

VMs in this subnet can have internal IPv6.

--logging-aggregation-interval=LOGGING_AGGREGATION_INTERVAL

Can only be specified if VPC Flow Logs for this subnetwork is enabled. Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Default is an interval of 5 seconds per connection. LOGGING_AGGREGATION_INTERVAL must be one of: interval-10-min, interval-15-min, interval-1-min, interval-30-sec, interval-5-min, interval-5-sec.

--logging-filter-expr=LOGGING_FILTER_EXPR

Can only be specified if VPC Flow Logs for this subnetwork is enabled. Export filter used to define which logs should be generated.

--logging-flow-sampling=LOGGING_FLOW_SAMPLING

Can only be specified if VPC Flow Logs for this subnetwork is enabled. The value of the field must be in [0, 1]. Set the sampling rate of VPC flow logs within the subnetwork where 1.0 means all collected logs are reported and 0.0 means no logs are reported. Default is 0.5 which means half of all collected logs are reported.

--logging-metadata=LOGGING_METADATA

Can only be specified if VPC Flow Logs for this subnetwork is enabled. Configures whether metadata fields should be added to the reported logs. Default is to exclude all metadata. LOGGING_METADATA must be one of: custom, exclude-all, include-all.

--logging-metadata-fields=[METADATA_FIELD,...]

Can only be specified if VPC Flow Logs for this subnetwork is enabled and "metadata" is set to CUSTOM_METADATA. The comma-separated list of metadata fields that should be added to reported logs.

--private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPE

The private IPv6 google access type for the VMs in this subnet. PRIVATE_IPV6_GOOGLE_ACCESS_TYPE must be one of: disable, enable-bidirectional-access, enable-outbound-vm-access.

--purpose=PURPOSE

The purpose of this subnetwork. PURPOSE must be one of:

INTERNAL_HTTPS_LOAD_BALANCER

Reserved for Internal HTTP(S) Load Balancing.

PRIVATE

Regular user created or automatically created subnet.

PRIVATE_SERVICE_CONNECT

Reserved for Private Service Connect Internal Load Balancing.

REGIONAL_MANAGED_PROXY

Reserved for Regional HTTP(S) Load Balancing.

--region=REGION

Region of the subnetwork to create. If not specified, you might be prompted to select a region (interactive mode only).

To avoid prompting when this flag is omitted, you can set the compute/region property:

$ gcloud config set compute/region REGION

A list of regions can be fetched by running:

$ gcloud compute regions list

To unset the property, run:

$ gcloud config unset compute/region

Alternatively, the region can be stored in the environment variable CLOUDSDK_COMPUTE_REGION.

--role=ROLE

The role of subnetwork. This field is required when the purpose is set to REGIONAL_MANAGED_PROXY or INTERNAL_HTTPS_LOAD_BALANCER. ROLE must be one of:

ACTIVE

The ACTIVE subnet that is currently used.

BACKUP

The BACKUP subnet that could be promoted to ACTIVE.

--secondary-range=PROPERTY=VALUE,[...]

Adds a secondary IP range to the subnetwork for use in IP aliasing.

For example, --secondary-range range1=192.168.64.0/24 adds a secondary range 192.168.64.0/24 with name range1.

RANGE_NAME - Name of the secondary range.

RANGE - IP range in CIDR format.

--stack-type=STACK_TYPE

The stack type for this subnet. Determines if IPv6 is enabled on the subnet. If not specified IPV4_ONLY will be used. STACK_TYPE must be one of:

IPV4_IPV6

New VMs in this subnet can have both IPv4 and IPv6 addresses

IPV4_ONLY

New VMs in this subnet will only be assigned IPv4 addresses

GCLOUD WIDE FLAGS

These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.

Run $ gcloud help for details.

NOTES

These variants are also available:

$ gcloud alpha compute networks subnets create

$ gcloud beta compute networks subnets create