Trying to get the standard CI/CD pattern working for Genesys Cloud CX as Code. The goal is to run terraform plan when a PR is opened and terraform apply only on merge to main.
We are using Azure DevOps with a YAML pipeline. The backend is configured to use an Azure Storage Container for remote state, just like the docs suggest for team environments.
The apply step works fine on the main branch. But when I open a PR, the pipeline fails immediately during the plan stage. The error is:
Error: Error loading state: stat /dev/shm/terraform.tfstate: no such file or directory
Here is the relevant part of the azure-pipelines.yml:
jobs:
- job: Plan
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
steps:
- script: |
terraform init -backend-config=storage_account_name=$(TF_BACKEND_STORAGE_ACCOUNT) -backend-config=container_name=$(TF_BACKEND_CONTAINER) -backend-config=key=gc-prod.tfstate
terraform plan -out=tfplan
displayName: 'Terraform Plan'
The terraform init step succeeds. It downloads the plugin and connects to Azure. But terraform plan can’t find the state file. I checked the storage account and the file exists.
Is there a specific flag needed for terraform plan in a non-apply context? Or is the backend config not persisting between the init and plan commands in the same job?
We’ve tried adding -input=false but that didn’t help. The docs just say “use remote state” but don’t show the exact pipeline syntax for Azure DevOps.