Automating IaC in CI/CD: Building a Production-Grade GitHub Actions Pipeline

Continuous Integration and Delivery for cloud infrastructure. How to configure OIDC passwordless authentication, speculative pull request validation, automated cost checks, and safe production deployments.

1. The Infrastructure Delivery Lifecycle

Executing cloud changes manually from an engineer's laptop creates severe security and reliability hazards. A mature DevOps practice enforces that all cloud changes flow exclusively through an automated, audited CI/CD pipeline.

The standard multi-stage pipeline consists of:

  1. Pull Request Trigger: When code is submitted, the runner validates syntax, scans for security flaws, runs a speculative plan, and computes cost estimates.
  2. Automated Review Bot: The runner comments directly on the pull request with a human-readable diff and cost impact breakdown.
  3. Mandatory Approvals: Two senior engineers and the security desk sign off on the plan diff.
  4. Merge to Main: Merging automatically executes apply against production and updates the remote state backend.
Advertisement
TellIaC is supported by compliant advertising to keep open documentation and tools freely accessible.

2. Eliminating Long-Lived Cloud Keys with OpenID Connect (OIDC)

Storing static cloud credentials (such as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) inside GitHub Secrets introduces the danger of credential leakage.

Modern best practices utilize OpenID Connect (OIDC). GitHub Actions requests short-lived temporary security tokens directly from AWS STS, Azure Active Directory, or Google Cloud Workload Identity Federation:

# Configuring passwordless OIDC in GitHub Actions
permissions:
  id-token: write  # Mandatory for requesting JWT token
  contents: read

steps:
  - name: Authenticate to AWS via OIDC
    uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsTellIaCRole
      aws-region: us-east-1

3. Complete Production GitHub Actions Workflow

Below is a complete, production-ready workflow for automating TellIaC validation and cost checks on pull requests:

name: TellIaC Infrastructure CI/CD Pipeline

on:
  pull_request:
    branches: [ main, production ]
  push:
    branches: [ main, production ]

jobs:
  validate-and-plan:
    name: Validate, Lint & Plan
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v4

      - name: Setup Python Runtime
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install TellIaC Engine
        run: |
          python -m pip install --upgrade pip
          pip install telliac

      - name: Validate Grammar & DAG Graphs
        run: telliac validate

      - name: Run Security Static Analysis
        run: telliac lint

      - name: Calculate Monthly Cloud Cost Delta
        run: telliac cost --env production

      - name: Generate Speculative Infrastructure Plan
        run: telliac plan

      - name: Verify Terraform HCL Exporter
        run: telliac export --out-dir ./tf_export_test
💡
Branch Protection Settings In your GitHub repository settings, enable "Require status checks to pass before merging" and select validate-and-plan. This guarantees invalid grammar or insecure configurations can never be merged.

Next in the Series: Diagnose and troubleshoot common cloud provisioning failures:
Troubleshooting Common Cloud IaC Errors, API Rate Limits & Resource Deadlocks →