jf terraform
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
- Terraform must be installed.
- Run
jf terraform-configin the project directory before the first operation. - Configure a server with
jf config addorjf c add. - Authentication to Artifactory is required.
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:
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.
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.
Expected Output
$ jf terraform-config --server-id-deploy=my-server --repo-deploy=terraform-local
Terraform build configuration saved successfully.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/terraform.yamlBuild: jf terraform
jf terraformRun Terraform commands with Artifactory provider integration and optional build-info collection.
To publish Terraform modules to Artifactory:
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 (mandatory for provider config) |
--project | — | JFrog Artifactory project key |
--provider | — | Terraform provider (mandatory for provider config) |
--tag | — | Terraform package tag (mandatory for provider config) |
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 (e.g.,example,myorg)<provider>is the Terraform provider name (e.g.,aws,azure,gcp)<tag>is the version tag (e.g.,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 provider configuration commands. - 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 |
|---|---|---|
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 |
| "namespace, provider, or tag is missing" | 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 |
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 8 days ago
