NDFC and Terraform
DCNM Terraform Provider

Introduction to Terraform

While a complete discussion around Terraform is outside the scope of this Lab, this section provides some basic background information to ensure that you understand Terraform operations and functions. If you used Terraform in previous Learning Labs or other sessions, feel free to skip this page and move on.

Terraform Providers

Unlike Ansible, Terraform is a precompiled, single binary application. However, this binary does not include any built-in ability to apply configuration to or read configuration from any device. This functionality is given through the installation of a provider, a set of resource and data source declarations that instruct Terraform how to interact with a device's REST APIs. Terraform has no ability to interact with any device via SSH, so any provider operates solely using APIs.

Providers are not hosted within Hashicorp's infrastructure. A provider owner places it within their own repository and registers the provider to the Terraform Registry. The registry enables anyone to use the provider through a declaration at the top of any HCL file. You can also reference a provider that is not registered within the public registry, either in an organization's VCS or using a private Terraform registry.

A provider declaration for NDFC looks like the following example,

Provider Name

The NDFC Terraform provider was originally developed for DCNM. NDFC support was added after version 1.2. For backward compatibility, the resource, datasource and provider names were retained, so the provider is still called dncm. A platform parameter is used to distingush the target's platform. Below, we have set the platform parameter to 'nd' for use with NDFC. To use the provider with DCNM controllers running versions prior to 1.2, you would set the platform parameter to 'dcnm'.

    
    terraform {
      required_providers {
        dcnm = {
          source  = "CiscoDevNet/dcnm"
          version = "1.2.7"
        }
      }
    }
    provider "dcnm" {
      username = "admin"
      password = "password"
      url      = "https://my-cisco-dcnm.com"
      insecure = true
      platform = "nd"
    }
    

After the declaration, you place the HCL configuration that is required to move the end device to the desired state. The provider is not downloaded and installed, however, until a terraform init process is executed.

Terraform Documentation

All documentation for each (public) provider can be found through the Terraform Registry. Each provider listing has information about the general use of the provider, as well as the specific resources (items to which configuration can be applied) and data sources (items from which configuration can be read).

  • Introduction
  • NDFC and Terraform
  • Envrionment and Topology
  • Task01 Interface Module
  • Task02 Overlay Module
  • Task03 CI/CD Pipeline
  • Bonus: Policy Module
  • Thanks