terraform-github-actions icon indicating copy to clipboard operation
terraform-github-actions copied to clipboard

backend_config read as file in apply

Open RossComputerGuy opened this issue 2 years ago • 4 comments

Problem description

When specifying the backend_config, I get errors about expecting a file. It should work but does not seem to align with according to how the documentation is. https://github.com/dflook/terraform-github-actions/tree/main/terraform-apply#inputs

Terraform version

1.5.5

Backend

s3

Workflow YAML

name: CI

on:
  push:
    branches:
      - master

jobs:
  plan:
    name: Apply to GKE
    if: ${{ github.repository_owner == 'ExpidusOS' }}
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
      pull-requests: write
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    strategy:
      matrix:
        region: [us-west1]
    steps:
      - uses: actions/checkout@v3
      - id: 'auth'
        name: 'Authenticate to Google Cloud'
        uses: 'google-github-actions/[email protected]'
        with:
          token_format: 'access_token'
          workload_identity_provider: 'projects/769178210270/locations/global/workloadIdentityPools/ci-pool/providers/github'
          service_account: '[email protected]'
      - id: get-gke-credentials
        uses: google-github-actions/[email protected]
        with:
          cluster_name: infra-${{ matrix.region }}
          location: ${{ matrix.region }}
      - name: Write variables
        run: |
          cat << EOF > terraform.tfvars
          region = "${{ matrix.region }}"
          aws_access_key_id = "${{ secrets.WASABI_ACCESS_KEY }}"
          aws_secret_access_key = "${{ secrets.WASABI_SECRET_KEY }}"
          EOF
      - name: Apply
        uses: dflook/[email protected]
        with:
          auto_approve: true
          backend_config: |
            bucket = "expidusos-ci"
            key = "infra/${{ matrix.region }}/terraform.tfstate"
            endpoint = "s3.us-west-1.wasabisys.com"
            region = "us-west-1"
            access_key = ${{ secrets.WASABI_ACCESS_KEY }}
            secret_key = ${{ secrets.WASABI_SECRET_KEY }}

Workflow log

Installing Terraform
  gpg: Signature made Tue Apr 19 07:39:49 2022 UTC
  gpg:                using RSA key 374EC75B485913604A831CC7C820C6D5CD27AB87
  gpg: Good signature from "HashiCorp Security (hashicorp.com/security) <[email protected]>" [ultimate]
  terraform_0.9.1_linux_amd64.zip: OK
  gpg: Signature made Wed Aug  9 13:10:01 2023 UTC
  gpg:                using RSA key 374EC75B485913604A831CC7C820C6D5CD27AB87
  gpg: Good signature from "HashiCorp Security (hashicorp.com/security) <[email protected]>" [ultimate]
  terraform_1.5.5_linux_amd64.zip: OK
  Terraform version not specified, using the latest version
  Switched to Terraform v1.5.5
  Detected s3 backend
Initializing Terraform
  
  Initializing the backend...
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "bucket" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "\"expidusos-ci\"" could not be read.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "key" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "\"infra/us-west1/terraform.tfstate\"" could not be read.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "endpoint" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "\"s3.us-west-1.wasabisys.com\"" could not be read.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "region" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "\"us-west-1\"" could not be read.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "access_key" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "***" could not be read.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "secret_key" could not be read.
  ╵
  
  ╷
  │ Error: Invalid backend configuration argument
  │ 
  │ The backend configuration argument "" given on the command line is not
  │ expected for the selected backend type.
  ╵
  
  ╷
  │ Error: Failed to read file
  │ 
  │ The file "***" could not be read.
  ╵

RossComputerGuy avatar Aug 17 '23 06:08 RossComputerGuy