smc-explorer is a companion tool for the forcepoint terraform smc provider. It allows to dump the elements already existing in the smc in hcl format and obtain the names and types of resources to use as a reference in your terraform config files (eg "tcp_service/SSH").
- python >=3.10
(you can use pip instead of pipx)
# install
$ pipx install --force git+https://github.com/Forcepoint/fp-ngfw-smc-explorer.git
# configure credentials
$ export TF_VAR_smc_apikey="xxxxxx"
$ export TF_VAR_smc_url="http://localhost:8082"
$ export TF_VAR_smc_ver="7.3"
# explore resources using "list" and "show"
$ smc-explorer list
...
$ smc-explorer show tcp_service/SSH
...
$ smc-explorer show 'fw_policy/Lab FW1/fw_ipv4_access_rules/Rule @2097357.0' -f json
...
$ smc-explorer show single_fw/myfw -o /tmp/myfw.tf(you can use pip instead of pipx)
pipx install --force git+https://github.com/Forcepoint/fp-ngfw-smc-explorer.gitto uninstall:
pipx uninstall smc-exploreruvx --from git+https://github.com/Forcepoint/fp-ngfw-smc-explorer.git smc-exploreruv tool install git+https://github.com/Forcepoint/fp-ngfw-smc-explorer.gitto uninstall:
uv tool uninstall smc-explorergit clone https://github.com/Forcepoint/fp-ngfw-smc-explorer.git
make installthe variables names are the same as the smc terraform provider attributes.
export TF_VAR_url="http://localhost:8082"
export TF_VAR_api_key="xxxxxx"
export TF_VAR_api_version="7.4"note: you might encounter a problem with the smc CA certificate if installing smc-explorer with python 3.13 (certificate verify failed: Path length given without key usage keyCertSign). In this case:
- use python 3.12
- disable verify_ssl
- sign with your own CA
export TF_VAR_url="https://localhost:8082"
export TF_VAR_api_key="xxxxxx"
export TF_VAR_api_version="7.4"
export TF_VAR_trusted_cert="$(cat certificate1768396249572.crt)"
export TF_VAR_verify_ssl=trueecho 'eval "$(_SMC_EXPLORER_COMPLETE=bash_source smc-explorer)"' >> ~/.bashrcecho 'eval "$(_SMC_EXPLORER_COMPLETE=zsh_source smc-explorer)"' >> ~/.zshrcecho '_SMC_EXPLORER_COMPLETE=fish_source smc-explorer | source' > ~/.config/fish/completions/smc-explorer.fishif you have installed the script in ~/.local/bin
~/.local/bin/smc-explorer$ smc-explorer list$ smc-explorer list 'fw_policy'$ smc-explorer list 'fw_policy/Lab FW1'$ smc-explorer list 'fw_policy/Lab FW1/fw_ipv4_access_rules/Rule @2097357.0'$ smc-explorer show 'fw_policy/Lab FW1/fw_ipv4_access_rules/Rule @2097357.0'This sub-command has several options:
-h, --help show this help message and exit -f, --format {json,hcl,yaml,toml} -r, --raw -o, --output OUTPUT -n, --name NAME rename resource -s, --skip SKIP skip attributes (comma separated) -k, --keep KEEP keep attributes (comma separated) -x, --extra-clean hide attr with false, -1, empty array and empty strings (use with care !!!)
it is possible to use wildcards to specify the attributes to skip. the command below removes the alias_value and antivirus attributes.
smc-explorer show single_fw/myfw -x -s alias_value,antivirusit is possible to use wildcards to specify the attributes to keep. the command below gives a summary of the firewall
smc-explorer show single_fw/myfw -k '*interface*,name,address'smc-explorer show single_fw/myfw -x -s alias_value,antivirus -k '*interface*,name,address'in the example below, we follow the "default_alias_value" attribute. the path part expression must be in jmespath syntax
$ smc-explorer show 'alias/$ Allowed SSH Local Sources'
resource "alias" "$ Allowed SSH Local Sources" {
admin_domain = "http://localhost:8082/7.4/elements/admin_domain/1"
default_alias_value = ["http://localhost:8082/7.4/elements/address_range/1"]
locked = false
name = "$ Allowed SSH Local Sources"
trashed = false
}
$ smc-explorer show 'alias/$ Allowed SSH Local Sources/default_alias_value[0]'
resource "address_range" "NONE" {
admin_domain = "http://localhost:8082/7.4/elements/admin_domain/1"
ip_range = "0.0.0.0"
locked = false
name = "NONE"
trashed = false
}
$ smc-explorer show single_fw/Plano -f json$ smc-explorer show 'http://localhost:8082/7.3/elements/user_id_service/4309'$ smc-explorer delete host/AExampleHost$ smc-explorer get-url host/AExampleHost- log is in /tmp/smc-explorer.log
- export SMC_EXPLORER_DEBUG=all
you need
- python >=3.10
- make
- uv (can be installed via pip)
pip install uvgit clone https://github.com/Forcepoint/fp-ngfw-smc-explorer.git
this installs smc-explorer in ~/.local/bin
make installuv run smc-explorer