A ready-to-use CI/CD Pipeline for managing your infrastructure with Terraform.
Run the following command in your project:
fluentci run terraform_pipeline
Or, if you want to use it as a template:
fluentci init -t terraform
This will create a .fluentci
folder in your project.
Now you can run the pipeline with:
fluentci run .
Use as a Dagger module:
dagger install github.com/fluent-ci-templates/terraform-pipeline@main
Call functions from the module:
dagger call init --src . \
--google-application-credentials /path/to/credentials.json
dagger call validate --src .
dagger call plan --src . \
--google-application-credentials /path/to/credentials.json
dagger call apply --src . \
--google-application-credentials /path/to/credentials.json
Variable | Description |
---|---|
TF_VERSION | The Terraform version to use. Defaults to latest |
TF_CLOUD_ORGANIZATION | The Terraform Cloud organization to use |
TF_API_TOKEN | The Terraform Cloud API token |
TF_WORKSPACE | The Terraform Cloud workspace to use |
TF_LOG | The Terraform log level |
TF_LOG_PATH | The Terraform log path |
TF_INPUT | Whether to ask for input |
TF_VAR_* | Terraform variables |
TF_CLI_ARGS | Additional Terraform CLI arguments |
TF_CLI_ARGS_* | Additional Terraform CLI arguments |
TF_DATA_DIR | The Terraform data directory |
TF_WORKSPACE | The Terraform workspace |
TF_IN_AUTOMATION | Whether Terraform is running in CI |
TF_REGISTRY_DISCOVERY_RETRY | Whether to enable registry discovery |
TF_REGISTRY_CLIENT_TIMEOUT | The registry client timeout |
TF_CLI_CONFIG_FILE | The Terraform CLI config file |
TF_PLUGIN_CACHE_DIR | The Terraform plugin cache directory |
TF_IGNORE | Display ignored files and directories |
Job | Description |
---|---|
init | Initialize Terraform working directory |
validate | Validate the configuration files |
plan | Generate and show an execution plan |
apply | Builds or changes infrastructure |
init(
src: Directory | string | undefined = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise<string>
validate(
src: Directory | string = ".",
tfVersion?: string
): Promise<string>
plan(
src: Directory | string = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise<string>
apply(
src: Directory | string = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise<string>
You can also use this pipeline programmatically:
import { init, validate, plan, apply } from "jsr:@fluentci/terraform";
await init();
await validate();
await plan();
// await apply();