Skip to content

Pin Terraform to 1.16 in CI - #179

Merged
ale210 merged 1 commit into
mainfrom
pin-terraform-version
Aug 29, 2026
Merged

Pin Terraform to 1.16 in CI#179
ale210 merged 1 commit into
mainfrom
pin-terraform-version

Conversation

@ale210

@ale210 ale210 commented Aug 29, 2026

Copy link
Copy Markdown
Member

This repo's terraform {} block has no required_version, so the dflook plan/apply actions take whatever the newest Terraform release is on the day they run. CI has been silently upgrading itself since the repo was created.

terraform_version recorded in the state file, s3://hfla-ops-terraform-state:

Date Version Serial
2024-02-01 1.7.0 1
2024-03-02 1.7.0 35
2024-09-12 1.9.5 50
2025-10-09 1.13.3 65
2026-08-28 1.16.0 74

Nothing chose any of those versions. From the most recent plan run:

Switched to Terraform v1.16.0

Pinning at ~> 1.16.0 fixes major and minor while still allowing patch releases. 1.16 rather than anything older because state serial 74 was written by 1.16.0 and Terraform refuses to load a snapshot created by a newer version — an older pin would fail every plan and apply.

Same change as hackforla/incubator#182, where the constraint existed but was a component short (~> 1.12 instead of ~> 1.12.1, which allows all of 1.x). Incubator's original ticket is hackforla/incubator#38; this repo never had an equivalent.

Verification

  • The plan run on this PR reports Switched to Terraform v1.16.x and succeeds. Confirmed: Switched to Terraform v1.16.0, plan green, No changes.

Not in scope

  • .terraform.lock.hcl is gitignored, so provider versions float in CI too. The aws provider has no version constraint at all.

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

Terraform plan in terraform
With backend config files: terraform/prod.backend.tfvars

No changes. Your infrastructure matches the configuration.
No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

✅ Plan applied in Apply Terraform changes on merge #41

@ale210
ale210 merged commit f3ff294 into main Aug 29, 2026
2 checks passed
@ale210
ale210 deleted the pin-terraform-version branch August 29, 2026 22:12
ale210 added a commit to hackforla/incubator that referenced this pull request Aug 29, 2026
Terraform was never actually pinned in CI. `#38` asked for
`required_version = "~> 1.12.1"` — three components, which fixes major
and minor and allows patch. What landed in #109 was `"~> 1.12"`, one
component short, and a two-part `~>` constraint pins only the major: it
means `>= 1.12, < 2.0`, so every 1.x satisfies it.

The dflook plan/apply actions have no version input — they resolve the
constraint and take the newest release that matches. From today's plan
run:

```
Using latest Terraform version that matches the required_version constraints
Switched to Terraform v1.16.0
```

`terraform_version` recorded in the state file,
`s3://hfla-incubator-terraform-state`:

| Date | Version | Serial |
|---|---|---|
| 2025-04-14 (pre-constraint) | 1.11.4 | 96 |
| 2025-09-20 | 1.13.3 | 111 |
| 2025-10-18 | 1.13.4 | 126 |
| 2026-08-11 | 1.15.8 | 136 |
| 2026-08-29 | 1.16.0 | 140 |

It has never run a 1.12.x under the constraint — 1.13 was already out
when #109 merged.

**Pinning forward to 1.16 rather than back to 1.12.** State serial 140
was written by 1.16.0, and Terraform refuses to load a snapshot created
by a newer version, so `~> 1.12.1` today would fail every plan and apply
outright. 1.16 is what is already deployed; #38's intent is recoverable,
its version target is not.

`hackforla/devops-security` has the same defect in a stronger form — no
`required_version` at all — and gets the matching change in
hackforla/devops-security#179.

### Verification

- [x] The plan run on this PR reports `Switched to Terraform v1.16.x`
and succeeds. Confirmed: `Switched to Terraform v1.16.0`, plan green,
`No changes.`

### Not in scope

- `terraform/backend.tf` is not `terraform fmt` clean on `main`
(`source` and `superuser` alignment); left alone.
- `.terraform.lock.hcl` is gitignored, so provider versions float in CI
too. Only `postgresql` is pinned; the `aws` provider has no constraint.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant