Skip to content

A ready-to-use CI/CD Pipeline for managing your infrastructure with Terraform.

License

Notifications You must be signed in to change notification settings

fluent-ci-templates/terraform-pipeline

Repository files navigation

Terraform Pipeline

fluentci pipeline deno compatibility dagger-min-version ci

A ready-to-use CI/CD Pipeline for managing your infrastructure with Terraform.

🚀 Usage

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 .

🧩 Dagger Module

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

🛠️ Environment variables

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

✨ Jobs

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>

👨‍💻 Programmatic usage

You can also use this pipeline programmatically:

import { init, validate, plan, apply } from "jsr:@fluentci/terraform";

await init();
await validate();
await plan();
// await apply();

About

A ready-to-use CI/CD Pipeline for managing your infrastructure with Terraform.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages