Loading...
Loading...
### Terraform Version ```shell Terraform v1.9.8 on linux_amd64 ``` ### Terraform Configuration Files ```sh set -euo pipefail echo "##[command]Run Terraform init" terraform -chdir=${{ parameters.baseDirectory }}/terraform init -input=false -reconfigure \ -backend-config="resource_group_name=$(resourceGroup)" \ -backend-config="storage_account_name=$(storageAccountTerraform)" \ -backend-config="container_name=${{ parameters.containerName }}" \ -backend-config="key=${{ parameters.terraformKey }}" echo "##[command]Run Terraform plan" terraform -chdir=${{ parameters.baseDirectory }}/terraform plan -input=false -out=tfplan $tfPlanOptions echo "##[command]Run Terraform apply" terraform -chdir=${{ parameters.baseDirectory }}/terraform apply -input=false -auto-approve tfplan ``` ### Debug Output ```console Terraform v1.9.8 on linux_amd64 Setting up environment variables for OIDC 45597f60-6e37-4be7-acfb-4c9e23b261ea, ca5e6314-439a-4af0-a4ef-489fecc630e3, ***, *** true Run Terraform init Initializing the backend... Successfully configured the backend "azurerm"! Terraform will automatically use this backend unless the backend configuration changes. Initializing provider plugins... - Finding hashicorp/azurerm versions matching "~> 3.90.0"... - Finding hashicorp/random versions matching "~> 2.3.0"... - Finding hashicorp/external versions matching "~> 1.2.0"... - Finding hashicorp/null versions matching ">= 3.2.1"... - Installing hashicorp/azurerm v3.90.0... - Installed hashicorp/azurerm v3.90.0 (signed by HashiCorp) - Installing hashicorp/random v2.3.1... - Installed hashicorp/random v2.3.1 (signed by HashiCorp) - Installing hashicorp/external v1.2.0... - Installed hashicorp/external v1.2.0 (signed by HashiCorp) - Installing hashicorp/null v3.2.3... - Installed hashicorp/null v3.2.3 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. Run Terraform plan 2024-11-14T14:06:34.308Z [ERROR] provider: error encountered while scanning stdout: error="read |0: file already closed" 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. Run Terraform apply Apply complete! Resources: 0 added, 0 changed, 0 destroyed. ``` ### Expected Behavior terraform plan should return exit code `1` when it encounters "[ERROR] provider: error encountered while scanning stdout: error="read |0: file already closed" ### Actual Behavior Terraform plan returns exit code `0` ### Steps to Reproduce ``` $ terraform init $ terraform plan ``` ### Additional Context The above script is executed as part of an Azure Devops pipeline deploying some resources to Azure. ´set -euo pipefail´ instructs a bash script to terminate immediately with the current exit code in case an error is encountered. This however is not the case as per above log output, from which we conclude that terraform plan returned 0 instead of 1. It is unclear what lead to the error in the first place, I suspect it was a network connection that was unexpectedly terminated. The issue is hard to reproduce. A secondary issue to this problem is that the lock on the statefile in the associated Azure storage account is not removed. Due to the lack of error propagation, this goes undetected from a pipeline execution perspective, and causing the next run to fail. ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.