less than 1 minute read

Today I’ve faced small but nasty bug in my Terraform solution. You can read about solution in Terraform vs Github Actions and Github actions matrix secrets articles.

After one unsuccessful run, Terraform state became locked. Pipeline had following message:


This plan was saved to: planfile

To perform exactly these actions, run the following command to apply:
    terraform apply "planfile"

Error: The operation was canceled.

As it turned out, Github actions uses fail-fast strategy by default for matrix jobs.

With that strategy, when one job will be failed, all other jobs will be cancelled. Applied to Terraform, it results in permamently locked state.

To fix this, we need disable fail-first. With that, my matrix strategy looks following:

jobs:
  validate-job:
    strategy:
      fail-fast: false
      matrix:
        include:
          - environment: tst
            client_id: TST_TF_ARM_CLIENT_ID
            client_secret: TST_TF_ARM_CLIENT_SECRET
            subscription_id: TST_TF_ARM_SUBSCRIPTION_ID
          - environment: acc
            client_id: ACC_TF_ARM_CLIENT_ID
            client_secret: ACC_TF_ARM_CLIENT_SECRET
            subscription_id: ACC_TF_ARM_SUBSCRIPTION_ID
          - environment: prd
            client_id: PRD_TF_ARM_CLIENT_ID
            client_secret: PRD_TF_ARM_CLIENT_SECRET
            subscription_id: PRD_TF_ARM_SUBSCRIPTION_ID`

Comments