This example demonstrates how to publish terraform modules to Artifactory.
- Create a local Terraform repository in Artifactory.
- Make sure version 2.12.0 or above of JFrog CLI is installed.
In your terminal, validate that the following commands work.
Output JFrog CLI version:
> jf --v
CD to the root project directory
Configure Artifactory:
> jf c add
Configure the project's deployment repository. You shoud set the local repository you created.
> jf tfc
CD to directory which contains the modules. for example "aws" directory.
> cd aws
Publish modules to Artifactory:
> jf tf p --namespace=example --provider=aws --tag=v0.0.1
You can exclude files and directories from being scanned by the commandm using the --exclusions option. In this example, files and directories which include test or ignore anywhere in their path, won't be scanned.
> jf tf p --namespace=example --provider=aws --tag=v0.0.2 --exclusions="*test*;*ignore*"
The jf tf command scans the local file-system under the current working directory recursively. It searches for directories which includes at least one file with a .tf extension. Such a directory is assumed to be a terraform module, and it is therefore packed into one zip file (including submodules directories) and then published to Artifactory. There isn't any recursive scanning inside the module directory after it is packed. This means that sub-nodules aren't packed and deployed separately to Artifactory.