Export devices from netbox to terraform variables.
Script gets information about devices and virtual machines from netbox and then forming a mapping variable in HCL format from template.
The result is exposed to scripts output and can be used in Terraform.
One of the usecases of this script is PagerDuty services and service dependencies configuration by Terraform.
Just run:
netbox2tf.py
And get HCL formatted text from script output.
The configuration is performed via environment variables contained in a .env file.
| Variable | Description | Example |
|---|---|---|
NETBOX_URL |
URL to your netbox. Mandatory. | https://netbox.my.domain |
NETBOX_KEY |
Multiline string with your netbox private RSA key. Mandatory. | See .env.example |
NETBOX_TOKEN |
Your netbox acceess token. Mandatory | Access token generated by netbox |
NETBOX_SSL_VERIFY |
Whether or not turn on SSL sertificate verification. Default is "True" | String "True" or "False" |
TF_FILE_TEMPLATE |
Jinja template file. Default is "nb-template.tf.j2" | nb-template.tf.j2 |
TF_VAR_NAME |
Name for variable name in HCL. Default is "nb_devices" | nb_devices |