Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fluent-ci-templates/terraform-pipeline

A ready-to-use CI/CD Pipeline for managing your infrastructure with Terraform.
https://github.com/fluent-ci-templates/terraform-pipeline

cicd dagger deno pipeline terraform typescript

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# Terraform Pipeline

[![fluentci pipeline](https://shield.fluentci.io/x/terraform_pipeline)](https://pkg.fluentci.io/terraform_pipeline)
![deno compatibility](https://shield.deno.dev/deno/^1.41)
[![dagger-min-version](https://shield.fluentci.io/dagger/v0.11.7)](https://dagger.io)
[![](https://jsr.io/badges/@fluentci/terraform)](https://jsr.io/@fluentci/terraform)
[![ci](https://github.com/fluent-ci-templates/terraform-pipeline/actions/workflows/ci.yml/badge.svg)](https://github.com/fluent-ci-templates/terraform-pipeline/actions/workflows/ci.yml)

A ready-to-use CI/CD Pipeline for managing your infrastructure with [Terraform](https://www.terraform.io/).

## 🚀 Usage

Run the following command in your project:

```bash
fluentci run terraform_pipeline
```

Or, if you want to use it as a template:

```bash
fluentci init -t terraform
```

This will create a `.fluentci` folder in your project.

Now you can run the pipeline with:

```bash
fluentci run .
```

## 🧩 Dagger Module

Use as a [Dagger](https://dagger.io) module:

```bash
dagger install github.com/fluent-ci-templates/terraform-pipeline@main
```

Call functions from the module:

```bash
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 |

```typescript
init(
src: Directory | string | undefined = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise

validate(
src: Directory | string = ".",
tfVersion?: string
): Promise

plan(
src: Directory | string = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise

apply(
src: Directory | string = ".",
tfVersion?: string,
googleApplicationCredentials?: string
): Promise
```

## 👨‍💻 Programmatic usage

You can also use this pipeline programmatically:

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

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

```