Skip to content

Going Further

This guide builds on First Steps and shows how to extend the configuration, override default values, organize larger deployments and remove resources. After each change, run nac validate, nac plan, nac apply and nac test again.

Let’s expand the configuration with a guest SSID and VLANs on the security appliance. Update data/networks.nac.yaml:

---
meraki:
domains:
- name: cisco.com # Replace with your domain
administrator:
name: admin@cisco.com # Replace with your admin email
organizations:
- name: Demo Organization # Replace with your organization
managed: false
networks:
- name: Branch-Office-Demo
product_types:
- appliance
- switch
- wireless
time_zone: America/Los_Angeles
notes: Branch office demo network
tags:
- demo
- branch
wireless:
ssids:
- name: Corporate-WiFi
ssid_number: "0"
enabled: true
auth_mode: psk
psk: DemoPassword123
encryption_mode: wpa
wpa_encryption_mode: WPA2 only
ip_assignment_mode: Bridge mode
use_vlan_tagging: true
default_vlan_id: 100
- name: Guest-WiFi
ssid_number: "1"
enabled: true
auth_mode: open
splash_page: Click-through splash page
appliance:
vlans:
- vlan_id: 100
name: Data VLAN
subnet: 10.1.100.0/24
appliance_ip: 10.1.100.1
dhcp_handling: Run a DHCP server
dhcp_lease_time: 1 day
- vlan_id: 200
name: Voice VLAN
subnet: 10.1.200.0/24
appliance_ip: 10.1.200.1
dhcp_handling: Run a DHCP server
dhcp_lease_time: 1 day

This adds:

  • A guest SSID with a click-through splash page
  • A data and a voice VLAN with a DHCP server on the security appliance

The module ships with default values for many attributes, which are documented in the Data Model section. You can override them in a defaults file, which can be named anything, as long as defaults: is at the root of the YAML structure and the remaining structure matches the data model path. Create data/defaults.nac.yaml:

---
defaults:
meraki:
domains:
organizations:
networks:
wireless:
ssids:
enabled: true
ip_assignment_mode: Bridge mode
use_vlan_tagging: false
switch:
settings:
vlan: 999
use_combined_power: true
uplink_client_sampling: true
mac_blocklist: false

The defaults file can also be placed in a separate directory, which then needs to be added to yaml_directories in main.tf, e.g. yaml_directories = ["data", "defaults"].

Defaults are only applied to objects that are defined in the data model. For example, the switch settings defaults above are only used if a network contains a switch.settings section. Values defined in the network take precedence over the defaults:

---
meraki:
domains:
- name: cisco.com
administrator:
name: admin@cisco.com
organizations:
- name: Demo Organization
managed: false
networks:
- name: Branch-Office-Demo
switch:
settings:
vlan: 1
use_combined_power: false

In this example, vlan and use_combined_power are set explicitly, while uplink_client_sampling and mac_blocklist are taken from the defaults file.

Lists of dictionaries, such as firewall rules, are not supported as default values. Only individual attributes can have defaults. For such use cases, we recommend using configuration templates. If you have a scenario where a list of dictionaries as default values would be required, please raise an issue on the module GitHub repository.

As your configuration grows, you can split it across multiple files in the data directory, as all of them are merged by the module.

For larger deployments, it is recommended to split the configuration into multiple directories, each with its own main.tf and Terraform state, for example per region. This keeps state files small and pipeline runs short, makes troubleshooting easier and limits the blast radius of potentially destructive changes. The nac commands are run from each of these directories:

emea/
├── main.tf
├── data/
│ ├── meraki.nac.yaml
│ ├── networks_branch.nac.yaml
│ ├── networks_campus.nac.yaml
│ ├── devices.nac.yaml
│ └── defaults.nac.yaml
apac/
├── main.tf
├── data/
│ ├── meraki.nac.yaml
│ ├── networks_branch.nac.yaml
│ ├── networks_campus.nac.yaml
│ ├── devices.nac.yaml
│ └── defaults.nac.yaml
lab/
├── main.tf
├── data/
│ ├── meraki.nac.yaml
│ ├── networks_branch.nac.yaml
│ ├── networks_campus.nac.yaml
│ ├── devices.nac.yaml
│ └── defaults.nac.yaml

To remove resources, you can either:

  1. Remove the configuration from your YAML files and run nac plan and nac apply
  2. Use nac destroy to remove all managed resources

For example, to remove the Guest-WiFi SSID, delete its configuration block from the YAML file and run:

Terminal window
nac plan
nac apply

Terraform detects the removed configuration and resets the SSID in your Meraki network.

Although a removed object is no longer managed by Terraform, not every resource is deleted from the Meraki Dashboard. Non-singleton resources are deleted, while singleton resources are typically left in place by the provider. For some singletons, such as traffic shaping or firewall rules, the module overrides this behavior to ensure that the configuration is removed from the Dashboard. If you feel there is an additional singleton resource that requires this behavior, please open an issue on the module GitHub repository.

This simple example demonstrates the core concepts of managing Meraki networks with Network as Code. You can extend this approach to:

  • Manage multiple organizations and networks
  • Configure advanced wireless features like splash pages and access control
  • Set up switch port configurations and VLAN assignments
  • Configure security appliance firewall rules and VPN settings
  • Implement reusable network and device configurations with configuration templates

For more advanced scenarios, explore the examples in the Data Model documentation and consider running the same nac commands in a CI/CD pipeline for automated deployments.