blob: 4adae633d69766534995b031a2e1c6500bd53eef [file]
---
layout: "cloudstack"
page_title: "CloudStack: cloudstack_network"
sidebar_current: "docs-cloudstack-resource-network"
description: |-
Creates a network.
---
# cloudstack_network
Creates a network.
## Example Usage
Basic usage:
```hcl
resource "cloudstack_network" "default" {
name = "test-network"
cidr = "10.0.0.0/16"
network_offering = "Default Network"
zone = "zone-1"
}
```
With IPv6 support:
```hcl
resource "cloudstack_network" "ipv6" {
name = "test-network-ipv6"
cidr = "10.0.0.0/16"
ip6cidr = "2001:db8::/64"
network_offering = "Default Network"
zone = "zone-1"
}
```
VPC network with automatic project inheritance:
```hcl
resource "cloudstack_vpc" "default" {
name = "test-vpc"
cidr = "10.0.0.0/8"
vpc_offering = "Default VPC Offering"
zone = "zone-1"
project = "my-project"
}
resource "cloudstack_network" "vpc_network" {
name = "test-vpc-network"
cidr = "10.1.0.0/16"
network_offering = "DefaultIsolatedNetworkOfferingForVpcNetworks"
vpc_id = cloudstack_vpc.default.id
zone = cloudstack_vpc.default.zone
# project is automatically inherited from the VPC
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the network.
* `display_text` - (Optional) The display text of the network.
* `cidr` - (Required) The CIDR block for the network. Changing this forces a new
resource to be created.
* `gateway` - (Optional) Gateway that will be provided to the instances in this
network. Defaults to the first usable IP in the range.
* `startip` - (Optional) Start of the IP block that will be available on the
network. Defaults to the second available IP in the range.
* `endip` - (Optional) End of the IP block that will be available on the
network. Defaults to the last available IP in the range.
* `ip6cidr` - (Optional) The IPv6 CIDR block for the network. Must be a valid
IPv6 CIDR (IPv4 CIDRs are rejected). The prefix must be at least `/127` (or
`/126` when the network offering has `specifyipranges` enabled) so that the
gateway and, when applicable, the IP range can be derived. Changing this
forces a new resource to be created.
* `ip6gateway` - (Optional) IPv6 Gateway that will be provided to the instances
in this network. Must fall within `ip6cidr`. Defaults to the second address
in the subnet (network address + 1, e.g., 2001:db8::1 for 2001:db8::/64).
* `startipv6` - (Optional) Start of the IPv6 block that will be available on the
network. Must fall within `ip6cidr`. Only applied when the network offering
has `specifyipranges` enabled; in that case it defaults to the second
available IP in the range (otherwise it is not sent to the API).
* `endipv6` - (Optional) End of the IPv6 block that will be available on the
network. Must fall within `ip6cidr`. Only applied when the network offering
has `specifyipranges` enabled; in that case it defaults to the last
available IP in the range (otherwise it is not sent to the API).
* `network_domain` - (Optional) DNS domain for the network.
* `network_offering` - (Required) The name or ID of the network offering to use
for this network.
* `vlan` - (Optional) The VLAN number (1-4095) the network will use. This might be
required by the Network Offering if specifyVlan=true is set. Only the ROOT
admin can set this value.
* `vpc_id` - (Optional) The VPC ID in which to create this network. Changing
this forces a new resource to be created.
* `acl_id` - (Optional) The ACL ID that should be attached to the network or
`none` if you do not want to attach an ACL. You can dynamically attach and
swap ACL's, but if you want to detach an attached ACL and revert to using
`none`, this will force a new resource to be created. (defaults `none`)
* `project` - (Optional) The name or ID of the project to deploy this
network to. Changing this forces a new resource to be created. If not
specified and `vpc_id` is provided, the project will be automatically
inherited from the VPC.
* `source_nat_ip` - (Optional) If set to `true` a public IP will be associated
with the network. This is mainly used when the network supports the source
NAT service which claims the first associated IP address. This prevents the
ability to manage the IP address as an independent entity.
* `zone` - (Required) The name or ID of the zone where this network will be
available. Changing this forces a new resource to be created.
* `bypass_vlan_overlap_check` - (Optional) if set to `true` it bypasses VLAN id/range overlap
check during network creation for shared and L2 networks
## Attributes Reference
The following attributes are exported:
* `id` - The ID of the network.
* `display_text` - The display text of the network.
* `gateway` - The IPv4 gateway of the network.
* `ip6gateway` - The IPv6 gateway of the network.
* `network_domain` - DNS domain for the network.
* `source_nat_ip_address` - The associated source NAT IP.
* `source_nat_ip_id` - The ID of the associated source NAT IP.
## Import
Networks can be imported; use `<NETWORK ID>` as the import ID. For
example:
```shell
terraform import cloudstack_network.default 36619b20-5584-43bf-9a84-e242bacd5582
```
When importing into a project you need to prefix the import ID with the project name:
```shell
terraform import cloudstack_network.default my-project/36619b20-5584-43bf-9a84-e242bacd5582
```