The Terraform Provider for AOS-CX provides a comprehensive set of configuration management resources specifically designed to manage and configure AOS-CX switches using the REST API. This provider enables Infrastructure as Code (IaC) practices for network infrastructure management.
- VLAN Management: Create, update, and delete VLANs
- Interface Configuration: Manage physical interfaces, L2 interfaces, and L3 interfaces
- VLAN Interface Management: Configure VLAN interfaces with routing capabilities
- Full Configuration Management: Apply complete switch configurations
- State Management: Track and manage configuration drift
- Terraform >= 0.13.x (recommended: >= 1.0)
- Go >= 1.24.1 (for development)
- AOS-CX switch with REST API enabled
- Network connectivity to the target switch
Add the following to your Terraform configuration:
terraform {
required_version = ">= 0.13"
required_providers {
aoscx = {
source = "aruba/aoscx"
version = "~> 1.0"
}
}
}
For local development and testing:
# Clone the repository
git clone https://github.com/felixn-unity/terraform-provider-aoscx.git
cd terraform-provider-aoscx
# Build the provider
go build -o terraform-provider-aoscx
# Install locally (optional)
mkdir -p ~/.terraform.d/plugins/local/aruba/aoscx/1.0.0/darwin_arm64
cp terraform-provider-aoscx ~/.terraform.d/plugins/local/aruba/aoscx/1.0.0/darwin_arm64/
Configure the provider with your AOS-CX switch connection details:
provider "aoscx" {
hostname = var.switch_hostname # IP address or hostname of the switch
username = var.switch_username # Username for authentication
password = var.switch_password # Password for authentication
}
Parameter | Type | Required | Description |
---|---|---|---|
hostname |
string | Yes | IP address or hostname of the AOS-CX switch |
username |
string | Yes | Username for REST API authentication |
password |
string | Yes | Password for REST API authentication |
Security Note: Use Terraform variables or environment variables for sensitive data. See Terraform's documentation on Protecting Sensitive Input Variables.
# variables.tf
variable "switch_hostname" {
description = "AOS-CX switch hostname or IP"
type = string
}
variable "switch_username" {
description = "AOS-CX switch username"
type = string
}
variable "switch_password" {
description = "AOS-CX switch password"
type = string
sensitive = true
}
# main.tf
provider "aoscx" {
hostname = var.switch_hostname
username = var.switch_username
password = var.switch_password
}
Resource | Description |
---|---|
aoscx_vlan |
Manage VLANs |
aoscx_interface |
Configure physical interfaces |
aoscx_l2_interface |
Configure Layer 2 interfaces |
aoscx_l3_interface |
Configure Layer 3 interfaces |
aoscx_vlan_interface |
Configure VLAN interfaces |
aoscx_full_config |
Apply complete switch configurations |
For detailed documentation on each resource, see the docs directory.
resource "aoscx_vlan" "production" {
vlan_id = 100
name = "production-vlan"
description = "Production network VLAN"
admin_state = "up"
}
resource "aoscx_vlan" "development" {
vlan_id = 200
name = "development-vlan"
description = "Development network VLAN"
admin_state = "up"
}
# Physical interface configuration
resource "aoscx_interface" "uplink" {
name = "1/1/1"
admin_state = "up"
description = "Uplink to core switch"
}
# L2 access interface
resource "aoscx_l2_interface" "server_port" {
interface = "1/1/10"
admin_state = "up"
description = "Server connection"
vlan_mode = "access"
vlan_tag = aoscx_vlan.production.vlan_id
}
# L2 trunk interface
resource "aoscx_l2_interface" "trunk_port" {
interface = "1/1/20"
admin_state = "up"
description = "Trunk to access switch"
vlan_mode = "trunk"
vlan_ids = [aoscx_vlan.production.vlan_id, aoscx_vlan.development.vlan_id]
native_vlan_tag = true
}
resource "aoscx_l3_interface" "management" {
interface = "1/1/30"
admin_state = "up"
description = "Management interface"
ip4_address = "192.168.1.1/24"
}
- Go 1.24.1 or later
- Terraform 0.13 or later
- Access to an AOS-CX switch for testing
# Clone the repository
git clone https://github.com/felixn-unity/terraform-provider-aoscx.git
cd terraform-provider-aoscx
# Install dependencies
go mod download
# Build the provider
go build -o terraform-provider-aoscx
# Run tests
go test ./...
# Set up test environment variables
export TF_VAR_switch_hostname="10.0.0.1"
export TF_VAR_switch_username="admin"
export TF_VAR_switch_password="password"
# Run acceptance tests
TF_ACC=1 go test ./... -v
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run tests and ensure they pass
- Submit a pull request
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
This project is licensed under the Apache License 2.0. See LICENSE for details.
- Latest: Upgraded to Go 1.24.1, updated dependencies to latest versions
- v1.0.0: Initial release with core AOS-CX resource support