Skip to content

Commit

Permalink
Add appliance vlan dhcp resource
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Nov 3, 2024
1 parent 66fd09b commit f00c6be
Show file tree
Hide file tree
Showing 13 changed files with 1,073 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Add `meraki_organization_early_access_features_opt_in` resource and data sources
- Add `meraki_switch_organization_ports_profile` resource and data sources
- Add `meraki_switch_organization_ports_profiles_automation` resource and data sources
- Add `meraki_appliance_vlan_dhcp` resource

## 0.1.2

Expand Down
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ test:
.PHONY: gen
gen:
go run gen/load_models.go
ifeq ($(SPEC_PATH),)
go run ./gen/generator.go X "$(NAME)"
else
go run ./gen/definition.go "$(SPEC_PATH)" "$(NAME)"
go run ./gen/generator.go "$(SPEC_PATH)" "$(NAME)"
endif
go run golang.org/x/tools/cmd/goimports -w internal/provider/
terraform fmt -recursive ./examples/
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
Expand Down
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: |-
- Add `meraki_organization_early_access_features_opt_in` resource and data sources
- Add `meraki_switch_organization_ports_profile` resource and data sources
- Add `meraki_switch_organization_ports_profiles_automation` resource and data sources
- Add `meraki_appliance_vlan_dhcp` resource

## 0.1.2

Expand Down
80 changes: 80 additions & 0 deletions docs/resources/appliance_vlan_dhcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "meraki_appliance_vlan_dhcp Resource - terraform-provider-meraki"
subcategory: "Appliances"
description: |-
This resource is meant to be used in addition to the meraki_appliance_vlan resource to configure DHCP settings for a VLAN. It requires the VLAN to be already configured on the appliance.
---

# meraki_appliance_vlan_dhcp (Resource)

This resource is meant to be used in addition to the `meraki_appliance_vlan` resource to configure DHCP settings for a VLAN. It requires the VLAN to be already configured on the appliance.

## Example Usage

```terraform
resource "meraki_appliance_vlan_dhcp" "example" {
network_id = "L_123456"
vlan_id = "1234"
dhcp_boot_options_enabled = false
dhcp_handling = "Run a DHCP server"
dhcp_lease_time = "1 day"
dns_nameservers = "upstream_dns"
mandatory_dhcp_enabled = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `network_id` (String) Network ID
- `vlan_id` (String) The VLAN ID of the new VLAN (must be between 1 and 4094)

### Optional

- `dhcp_boot_filename` (String) DHCP boot option for boot filename
- `dhcp_boot_next_server` (String) DHCP boot option to direct boot clients to the server to load the boot file from
- `dhcp_boot_options_enabled` (Boolean) Use DHCP boot options specified in other properties
- `dhcp_handling` (String) The appliance`s handling of DHCP requests on this VLAN. One of: `Run a DHCP server`, `Relay DHCP to another server` or `Do not respond to DHCP requests`
- Choices: `Do not respond to DHCP requests`, `Relay DHCP to another server`, `Run a DHCP server`
- `dhcp_lease_time` (String) The term of DHCP leases if the appliance is running a DHCP server on this VLAN. One of: `30 minutes`, `1 hour`, `4 hours`, `12 hours`, `1 day` or `1 week`
- Choices: `1 day`, `1 hour`, `1 week`, `12 hours`, `30 minutes`, `4 hours`
- `dhcp_options` (Attributes List) The list of DHCP options that will be included in DHCP responses. Each object in the list should have 'code', 'type', and 'value' properties. (see [below for nested schema](#nestedatt--dhcp_options))
- `dhcp_relay_server_ips` (List of String) The IPs of the DHCP servers that DHCP requests should be relayed to
- `dns_nameservers` (String) The DNS nameservers used for DHCP responses, either 'upstream_dns', 'google_dns', 'opendns', or a newline seperated string of IP addresses or domain names
- `mandatory_dhcp_enabled` (Boolean) Enable Mandatory DHCP on VLAN.
- `reserved_ip_ranges` (Attributes List) The DHCP reserved IP ranges on the VLAN (see [below for nested schema](#nestedatt--reserved_ip_ranges))

### Read-Only

- `id` (String) The id of the object

<a id="nestedatt--dhcp_options"></a>
### Nested Schema for `dhcp_options`

Required:

- `code` (String) The code for the DHCP option. This should be an integer between 2 and 254.
- `type` (String) The type for the DHCP option. One of: `text`, `ip`, `hex` or `integer`
- Choices: `hex`, `integer`, `ip`, `text`
- `value` (String) The value for the DHCP option


<a id="nestedatt--reserved_ip_ranges"></a>
### Nested Schema for `reserved_ip_ranges`

Required:

- `comment` (String) A text comment for the reserved range
- `end` (String) The last IP in the reserved range
- `start` (String) The first IP in the reserved range

## Import

Import is supported using the following syntax:

```shell
terraform import meraki_appliance_vlan_dhcp.example "<network_id>,<id>"
```
1 change: 1 addition & 0 deletions examples/resources/meraki_appliance_vlan_dhcp/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_appliance_vlan_dhcp.example "<network_id>,<id>"
9 changes: 9 additions & 0 deletions examples/resources/meraki_appliance_vlan_dhcp/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "meraki_appliance_vlan_dhcp" "example" {
network_id = "L_123456"
vlan_id = "1234"
dhcp_boot_options_enabled = false
dhcp_handling = "Run a DHCP server"
dhcp_lease_time = "1 day"
dns_nameservers = "upstream_dns"
mandatory_dhcp_enabled = true
}
134 changes: 134 additions & 0 deletions gen/definitions/appliance_vlan_dhcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Appliance VLAN DHCP
rest_endpoint: /networks/%v/appliance/vlans
put_create: true
no_delete: true
no_data_source: true
no_import: true
res_description: This resource is meant to be used in addition to the `meraki_appliance_vlan` resource to configure DHCP settings for a VLAN. It requires the VLAN to be already configured on the appliance.
doc_category: Appliances
test_variables: [test_org, test_network]
attributes:
- tf_name: network_id
type: String
reference: true
description: Network ID
example: L_123456
test_value: meraki_appliance_vlans_settings.test.network_id
- model_name: id
tf_name: vlan_id
type: String
mandatory: true
description: The VLAN ID of the new VLAN (must be between 1 and 4094)
example: "1234"
test_value: meraki_appliance_vlan.test.vlan_id
- model_name: dhcpBootFilename
type: String
exclude_test: true
description: DHCP boot option for boot filename
example: sample.file
- model_name: dhcpBootNextServer
type: String
exclude_test: true
description: DHCP boot option to direct boot clients to the server to load the boot file from
example: 1.2.3.4
- model_name: dhcpBootOptionsEnabled
type: Bool
description: Use DHCP boot options specified in other properties
example: "false"
- model_name: dhcpHandling
type: String
description: "The appliance`s handling of DHCP requests on this VLAN. One of: `Run a DHCP server`, `Relay DHCP to another server` or `Do not respond to DHCP requests`"
example: Run a DHCP server
enum_values:
[
Do not respond to DHCP requests,
Relay DHCP to another server,
Run a DHCP server,
]
- model_name: dhcpLeaseTime
type: String
description: "The term of DHCP leases if the appliance is running a DHCP server on this VLAN. One of: `30 minutes`, `1 hour`, `4 hours`, `12 hours`, `1 day` or `1 week`"
example: 1 day
enum_values: [1 day, 1 hour, 1 week, 12 hours, 30 minutes, 4 hours]
- model_name: dnsNameservers
type: String
description: The DNS nameservers used for DHCP responses, either 'upstream_dns', 'google_dns', 'opendns', or a newline seperated string of IP addresses or domain names
example: upstream_dns
- model_name: enabled
type: Bool
data_path: [mandatoryDhcp]
description: Enable Mandatory DHCP on VLAN.
example: "true"
- model_name: dhcpOptions
type: List
exclude_test: true
description: The list of DHCP options that will be included in DHCP responses. Each object in the list should have 'code', 'type', and 'value' properties.
attributes:
- model_name: code
type: String
id: true
mandatory: true
description: The code for the DHCP option. This should be an integer between 2 and 254.
example: "3"
- model_name: type
type: String
id: true
mandatory: true
description: "The type for the DHCP option. One of: `text`, `ip`, `hex` or `integer`"
example: text
enum_values: [hex, integer, ip, text]
- model_name: value
type: String
id: true
mandatory: true
description: The value for the DHCP option
example: five
- model_name: dhcpRelayServerIps
type: List
element_type: String
description: The IPs of the DHCP servers that DHCP requests should be relayed to
example: 192.168.2.100
exclude_test: true
- model_name: reservedIpRanges
type: List
exclude_test: true
description: The DHCP reserved IP ranges on the VLAN
attributes:
- model_name: comment
type: String
id: true
mandatory: true
description: A text comment for the reserved range
example: A reserved IP range
- model_name: end
type: String
id: true
mandatory: true
description: The last IP in the reserved range
example: 192.168.1.1
- model_name: start
type: String
id: true
mandatory: true
description: The first IP in the reserved range
example: 192.168.1.0
test_prerequisites: |
data "meraki_organization" "test" {
name = var.test_org
}
resource "meraki_network" "test" {
organization_id = data.meraki_organization.test.id
name = var.test_network
product_types = ["switch", "wireless", "appliance"]
}
resource "meraki_appliance_vlans_settings" "test" {
network_id = meraki_network.test.id
vlans_enabled = true
}
resource "meraki_appliance_vlan" "test" {
network_id = meraki_appliance_vlans_settings.test.network_id
appliance_ip = "192.168.1.2"
vlan_id = "1234"
name = "My VLAN"
subnet = "192.168.1.0/24"
}
2 changes: 1 addition & 1 deletion gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func updateDefinitions() {
}

if config.SpecEndpoint == "" {
log.Fatalf("Error parsing %q: missing spec_endpoint", path)
continue
}

cmd := exec.Command("go", "run", "gen/definition.go", config.SpecEndpoint, config.Name)
Expand Down
Loading

0 comments on commit f00c6be

Please sign in to comment.