Sample Meraki as Code repository for the Meraki as Code Learning Lab.
This repository provides a ready-to-use project structure for managing Meraki infrastructure as code. It uses Terraform, YAML data models, and the NaC Meraki module to declaratively define and deploy configuration to the Meraki Dashboard.
.
├── .ci/ # CI/CD helper scripts (GitLab comments, Webex notifications)
├── data/ # Your YAML data model files go here (empty by default)
├── lab-data/ # Pre-built YAML files for each lab exercise step
├── rules/ # Custom nac-validate Python rules for semantic validation
├── workspaces/ # Separate Terraform workspace for template rendering
├── tests/ # Templates for post-deployment testing with nac-test
├── .gitlab-ci.yml # GitLab CI/CD pipeline definition
├── main.tf # Root Terraform configuration
├── schema.yaml # YAML schema for data model validation
└── LICENSE
- Terraform >= 1.9.0 (or OpenTofu)
- Python 3.12
- Meraki API Key with full write access (Enable API access)
Clone and switch to the repository:
git clone --depth 1 https://github.com/netascode/nac-meraki-example meraki-as-code
cd meraki-as-codeSet environment variables (create a .env file):
export MERAKI_API_KEY=<your_api_key>
export secret_password=<your_secret_in_datamodel>
export org_email=<your_email>source .envCopy the desired configuration from lab-data/ into the data/ folder:
cp lab-data/01_create_org.nac.yaml data/Validate, plan, deploy, and test:
nac-validate --non-strict -s schema.yaml -r rules/ data/
terraform init
terraform plan
terraform apply
nac-test --templates tests/ --data data/ --output test_results- NaC Meraki Terraform Module
- Meraki Terraform Provider
- Meraki Data Model Reference
- nac-validate
- nac-test
See the LICENSE file for details.