For CI/CD pipelines and automated deployments, using environment variables is often more secure and convenient than storing credentials in configuration files. Terraform automatically detects and uses host-specific environment variables.
Setting Up Environment Variables
Set the JFrog URL.
export JFROG_URL=https://[JFrogPlatformURL]Set the Access Token.
export JFROG_ACCESS_TOKEN=your-access-token-here
Environment Variable Naming Convention
Terraform uses the following naming pattern for environment variables:
TF_VAR_<variable_name>for Terraform variablesHost-specific variables like
JFROG_URLandJFROG_ACCESS_TOKENfor provider configuration
CI/CD Pipeline Example
For GitHub Actions, GitLab CI, or other CI/CD systems:
# GitHub Actions example
- name: Configure JFrog credentials
run: |
echo "JFROG_URL=https://[JFrogPlatformURL]" >> $GITHUB_ENV
echo "JFROG_ACCESS_TOKEN=${{ secrets.JFROG_ACCESS_TOKEN }}" >> $GITHUB_ENVBenefits of Environment Variable Approach
Security: Credentials are not stored in version control
Simplicity: No need to create or manage configuration files
Flexibility: Easy to switch between different environments
CI/CD Friendly: Seamless integration with automated deployment pipelines
Fallback to Configuration File
If environment variables are not set, Terraform will fall back to:
CLI configuration file (
~/.terraformrcor%APPDATA%\terraform.rc)Terraform configuration files (
.tffiles)
To learn more, see Terraform CLI configuration.