terraform-provider-aws
terraform-provider-aws copied to clipboard
[Bug]: Failed to marshal plan to json, unsupported attribute "override_json"
Terraform Core Version
1.4.6
AWS Provider Version
5.0.1
Affected Resource(s)
Converting a saved plan file into json using terraform show -json
results in this error
Failed to marshal plan to json: error marshaling prior state: unsupported attribute "override_json"
Downgrading to anything less than 5.0.0, and the same command works
Expected Behavior
Plan is converted to json and displayed on the screen
Actual Behavior
I get the error: Failed to marshal plan to json: error marshaling prior state: unsupported attribute "override_json"
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Since terraform is not showing which TF code lines are causing this panic, it's not possible to show a snippet of the configs
Steps to Reproduce
- Try to convert a saved plan file into json and it fails
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None
Community Note
Voting for Prioritization
- Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
- Please see our prioritization guide for information on how we prioritize.
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
- If you are interested in working on this issue, please leave a comment.
- If this would be your first contribution, please review the contribution guide.
Maybe related to this change? https://github.com/hashicorp/terraform-provider-aws/issues/22906
For some reason, "override_json": null
exist in state, when it should be removed from the state
Example:
{
"version": 4,
"terraform_version": "1.3.9",
"serial": 13,
"lineage": "fe5ffc8a-776c-9548-36c5-0b43c266ccb1",
"outputs": {},
"resources": [
{
"mode": "data",
"type": "aws_iam_policy_document",
"name": "assume_role",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "1642520416",
"json": "",
"override_json": null,
"override_policy_documents": null,
"policy_id": null,
"source_json": null,
"source_policy_documents": null,
"statement": [],
"version": "2012-10-17"
},
"sensitive_attributes": []
}
]
},
{
"mode": "data",
"type": "aws_iam_policy_document",
"name": "iam_access",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "4064693197",
"json": "",
"override_json": null,
"override_policy_documents": null,
"policy_id": null,
"source_json": null,
"source_policy_documents": null,
"statement": [],
"version": "2012-10-17"
},
"sensitive_attributes": []
}
]
},
...
The same issue happens with source_json
{
"mode": "data",
"type": "aws_iam_policy_document",
"name": "assume_role",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "....",
"json": ....,
"override_json": null, // Deprecated field!!!!
"override_policy_documents": null,
"policy_id": null,
"source_json": null, // Deprecated field!!!!
"source_policy_documents": null,
Workaround: to fix the state without state manipulations, you need change resources which had the override_json
field, and then apply.
For example:
- In
data.aws_iam_policy_document
, changeSid
- Run
terraform apply
I have the same issue in TF 1.5.0 with AWS Provider 5.4.0
For me the workaround doesn't work because many of the aws_iam_policy_document data are managed by modules meaning a simple change of SID is not always possible
This is a sever issue and has already impacted a production workspace which seems now nigh on unrecoverable baring some drastic state manipulation 🫰
Any speedy progress would be greatly appreciated!
I encountered this while trying to delete from state in Terraform Cloud. As a workaround, I had to first checkout the main
branch version of my workspace, upgrade to AWS Provider 5, and terraform state refresh
to fixup the state. Following that I was able to delete resources from state.
Hi Team, We are also facing same issue when running plan for specific resource or module. Failed to marshal plan to json: error marshaling prior state: unsupported attribute "override_json" Is there any fix or workaround anyone has for this issue.
In my case I have managed to make it work by:
- Upgrading providers, previously had AWS version 4.37.0, now on 5.31.0:
terraform init -upgrade
- Performing a plan and apply - even without changes. In my case I had
"override_json": null
in state. After the upgrade these were gone and I could finish what I was trying to do - a state push.
Seeing this very consistently when doing a -target
'ed plan.
I just got this issue
`Failed generating plan JSON Exit code: 1
Failed to marshal plan to json: error marshaling prior state: unsupported attribute "override_json" Operation failed: failed generating plan JSON: failed running command (exit 1)`
I have external modules, so Im not able to perform simple SID change. Is there any other way to fix this?
I just got this issue
`Failed generating plan JSON Exit code: 1
Failed to marshal plan to json: error marshaling prior state: unsupported attribute "override_json" Operation failed: failed generating plan JSON: failed running command (exit 1)`
I have external modules, so Im not able to perform simple SID change. Is there any other way to fix this?
Look like i fixed my issue with running plan+apply on 4.x provider with changed SID in all "aws_iam_policy_document" resources that I handle, get it back on 5.x and it worked!
This functionality has been released in v5.41.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.