Introduction
This article outlines the troubleshooting steps and resolution for an issue encountered during a Terraform plan run in a production workspace, where plan JSON generation failed due to a bug in the AWS provider version 6.0.0.
Overview
During a deployment on a Terraform workspace in the production environment, the plan step failed unexpectedly. The process had worked correctly in the past. This article details the root cause, mitigation steps, and the resolution.
Procedures
1. Issue Summary and Impact
A deployment in the production environment failed during the Terraform plan step.
The error message observed was:
Failed generating plan JSON. Exit code: 1. Failed to marshal plan to JSON.
2. Troubleshooting and Actions Taken
-
Step 1: Reviewed logs to identify the root error.
Identified the following message in the logs:
Error: failed to decode identity: unsupported attribute 'account_id' - Step 2: Validated the Terraform configuration to ensure that all attributes were supported and correctly defined.
- Step 3: Triggered a new plan run with logging level set to TRACE to gather deeper diagnostic information.
- Step 4: Analysed enhanced logs and identified the issue as a bug in the AWS provider plugin, version 6.0.0.
- Step 5: Referenced a known GitHub Issue #43178 which confirmed the bug and its fix in version 6.2.0.
-
Step 6: Upgraded the aws provider version from 6.0.0 to 6.2.0 in the Terraform configuration:
terraform { required_providers { aws = { source = "hashicorp/aws" version = "6.2.0" } } }
- Step 7: Re-triggered the Terraform plan, which succeeded post-upgrade.
3. Resolution
Upgrading the AWS provider from version 6.0.0 to 6.2.0 resolved the issue and allowed successful generation of the plan.
Root Cause
A bug in the Terraform AWS provider version 6.0.0 prevented proper decoding of the account_id attribute, causing plan marshalling to fail. This issue is fixed in version 6.2.0.
Additional Information