Publish Terraform Modules with JFrog CLI
Run Terraform commands with Artifactory provider integration and optional build-info collection.
This topic covers the following tasks:
When to Use
Use jf terraform to publish Terraform providers and modules to Artifactory. This command packages and deploys Terraform artifacts — it does not wrap terraform init or terraform plan.
Prerequisites
- Configure a server with
jf config addorjf c add. - Authentication to Artifactory is required.
- A local Terraform repository must exist in Artifactory. Create one via Administration → Repositories → Add Repositories → Local, selecting Terraform as the package type.
- Run
jf terraform-configin the project directory before the first operation.
Note
: The
terraformCLI binary is not required.jf terraformpackages and publishes modules directly — it never invokes theterraformbinary.
Configuration: jf terraform-config
jf terraform-configGenerate Terraform configuration for deployment to Artifactory. Run this once per project before your first Terraform operation.
To configure Terraform for Artifactory:
- From your project directory, run
jf terraform-configwith--server-id-deployand--repo-deploy(see Non-Interactive Configuration with Flags). - Confirm
.jfrog/projects/terraform.yamlexists (see How to Verify).
Synopsis
jf terraform-config [options]
Aliases: tfc
Configuration Options
| Flag | Default | Description |
|---|---|---|
--global | false | Set to true for global configuration (all projects). Specific projects can override. |
--repo-deploy | — | Repository for artifacts deployment |
--server-id-deploy | — | Artifactory server ID for deployment. Configure with jf config add. |
Configuration Examples
View Help
jf terraform-config --helpNon-Interactive Configuration with Flags
jf terraform-config --server-id-deploy=<server-id> --repo-deploy=<repo-name>Where:
- <server-id>: The server ID configured using
jf config add - <repo-name>: The name of the Terraform repository in Artifactory
For example:
jf terraform-config --server-id-deploy=my-server --repo-deploy=terraform-localWhy Run Config First?
You must run jf terraform-config before using jf terraform for deployment. The config creates .jfrog/projects/terraform.yaml specifying the Artifactory repository for Terraform provider/module uploads. Without it, jf terraform does not know where to deploy artifacts.
Shortcut
: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible. Ensure the
.jfrog/projects/terraform.yamlfile does not already exist before running, or delete it first — if the file exists, the CLI prompts interactively:Configuration file already exists. Override it? (y/n), which blocks non-TTY environments.
Configuration Notes
- Deployment only: Terraform config supports artifact deployment but not resolution. Terraform providers are resolved via Terraform's own registry mechanism.
- Run once per project: Re-run when changing the deployment repository. If the config file already exists, the CLI will prompt for confirmation before overwriting.
Expected Output
$ jf terraform-config --server-id-deploy=my-server --repo-deploy=terraform-local
terraform build config successfully created.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/terraform.yamlExpected file contents:
version: 1
type: terraform
deployer:
repo: terraform-local
serverId: my-serverNote
: Unlike other build tools, there is no
resolversection — Terraform config supports deployment only.
Build: jf terraform
jf terraformRun Terraform commands with Artifactory provider integration and optional build-info collection.
To publish Terraform modules to Artifactory:
- Run
jf terraform-configin the project directory if you have not already (see Configuration). - From the module directory, run
jf terraform(orjf tf) with thepublishsubcommand and required--namespace,--provider, and--tagflags (see Build Examples).
Synopsis
jf terraform <terraform-arguments> [options]
Aliases: tf
Arguments
| Argument | Required | Description |
|---|---|---|
<terraform-arguments> | Yes | Terraform subcommand and options. Only publish (alias p) is supported. |
Build Options
| Flag | Default | Description |
|---|---|---|
--build-name | — | Build name for build-info. Requires --build-number. |
--build-number | — | Build number for build-info. Requires --build-name. |
--exclusions | — | Semicolon-separated exclusions. Wildcards * and ? are supported. |
--module | — | Optional module name for build-info. Requires --build-name and --build-number. |
--namespace | — | Terraform namespace. Required for all publish operations. |
--project | — | JFrog Artifactory project key |
--provider | — | Terraform provider. Required for all publish operations. |
--tag | — | Terraform package tag. Required for all publish operations. |
Build Examples
Publish a Terraform Module
The command creates a package for the Terraform module in the current directory and publishes it to the configured Terraform repository:
jf tf p --namespace=<namespace> --provider=<provider> --tag=<tag>Where:
<namespace>is the Terraform namespace (for example,example,myorg)<provider>is the Terraform provider name (for example,aws,azure,gcp)<tag>is the version tag (for example,v0.0.1)
For example:
jf tf p --namespace=example --provider=aws --tag=v0.0.1Publish with Exclusions
The published package will not include module paths matching test or ignore:
jf tf p --namespace=example --provider=aws --tag=v0.0.1 --exclusions="*test*;*ignore*"Publish with Build-Info
The published module will be recorded as an artifact of build my-build with build number 1:
jf tf p --namespace=example --provider=aws --tag=v0.0.1 --build-name=my-build --build-number=1
jf rt build-publish my-build 1Important Notes
- Mandatory flags:
--namespace,--provider, and--tagare required for all publish operations — both module and provider publishing. - Terraform providers: This command is used to publish and manage Terraform providers and modules in Artifactory, not for general Terraform workflows.
- Build-info: Use
--build-nameand--build-numberto track provider/module deployments.
CI/CD Example (GitHub Actions)
# .github/workflows/build.yml
steps:
- uses: actions/checkout@v4
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Configure Terraform
run: jf terraform-config --server-id-deploy=setup-jfrog-cli-server --repo-deploy=terraform-local
- name: Publish Terraform module
run: jf tf p --namespace=example --provider=aws --tag=v0.0.1 --build-name=my-terraform --build-number=${{ github.run_number }}
- name: Publish build info
run: jf rt build-publish my-terraform ${{ github.run_number }}Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
The repository '<name>' does not exist | Terraform repository not yet created in Artifactory | Create a local Terraform repository in Artifactory, then re-run jf terraform-config with the correct name |
no config file was found | jf terraform-config was not run | Run jf terraform-config in the project directory |
| 401 / 403 on publish | Invalid credentials or insufficient permissions | Re-run jf config add with a valid access token |
the --namespace, --provider and --tag options are mandatory | Required flags not provided | Pass --namespace, --provider, and --tag on every publish |
No .tf files found | Command run in wrong directory | Ensure you are in a directory containing Terraform module files |
| Unwanted files included in package | Test or doc files not excluded | Use --exclusions="*test*;*.md" to filter them out |
| Config step hangs in CI/CD | Existing config file triggers interactive prompt | Delete .jfrog/projects/terraform.yaml before re-running jf terraform-config in non-TTY environments |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Related Topics
- Build Tools Overview — Capabilities matrix and tool reference
- Native Mode — Supported packages with Native Mode
Updated about 1 month ago
