Skip to main content

Provision with Terraform

This page explains how to provision infrastructure using Terraform with FluentCI.

HashiCorp Terraform is an infrastructure-as-code (IaC) tool that lets you provision and manage cloud infrastructure. Terraform provides plugins called providers that let you interact with cloud providers and other APIs.

Before you begin

The instructions on this page assume that you are familiar with Terraform. In addition:

  • Have your Terraform project ready.
  • If you don't already have a project to provision with Terraform, you can create a default project by installing and initializing Terraform.
  • Make sure you have a main.tf file in your project root directory.

Using the Terraform Plugin

You can use FluentCI to provision infrastructure using Terraform with the terraform plugin without installing Terraform CLI on your machine. FluentCI will handle everything for you.

The following commands can be used to provision infrastructure using Terraform:

fluentci run --wasm terraform init
fluentci run --wasm terraform plan
fluentci run --wasm terraform apply

CI/CD pipeline integrations

The following examples show how to integrate FluentCI with popular CI providers to provision infrastructure using Terraform:

ci.yml
name: ci
on:
push:
branches:
- main
jobs:
tasks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Fluent CI
uses: fluentci-io/setup-fluentci@v5
- name: init
run: fluentci run --wasm terraform init
env:
GOOGLE_APPLICATION_CREDENTIALS: ./service-account.json
- name: validate
run: fluentci run --wasm terraform validate
env:
GOOGLE_APPLICATION_CREDENTIALS: ./service-account.json
- name: plan
run: fluentci run --wasm terraform plan
env:
GOOGLE_APPLICATION_CREDENTIALS: ./service-account.json
- name: apply
run: fluentci run --wasm terraform apply
env:
GOOGLE_APPLICATION_CREDENTIALS: ./service-account.json