Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Failed to marshal plan to json, unsupported attribute "override_json" #31637

Closed
kim0 opened this issue May 30, 2023 · 14 comments · Fixed by #36383
Closed

[Bug]: Failed to marshal plan to json, unsupported attribute "override_json" #31637

kim0 opened this issue May 30, 2023 · 14 comments · Fixed by #36383
Labels
bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@kim0
Copy link

kim0 commented May 30, 2023

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

@kim0 kim0 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels May 30, 2023
@github-actions
Copy link

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.

@jvisker
Copy link

jvisker commented May 30, 2023

Maybe related to this change? #22906

@MaxymVlasov
Copy link

MaxymVlasov commented Jun 6, 2023

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": []
        }
      ]
    },
...

@franciscoprin
Copy link

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,

@MaxymVlasov
Copy link

MaxymVlasov commented Jun 6, 2023

Workaround: to fix the state without state manipulations, you need change resources which had the override_json field, and then apply.

For example:

  1. In data.aws_iam_policy_document, change Sid
  2. Run terraform apply

@justinretzolk justinretzolk added service/iam Issues and PRs that pertain to the iam service. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 12, 2023
@tomer-ds
Copy link

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!

@carl-reverb
Copy link

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.

@Mukesh-Sharma-external
Copy link

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.

@ferschubert
Copy link

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.

@major0
Copy link

major0 commented Feb 21, 2024

Seeing this very consistently when doing a -target'ed plan.

@muhamedkapoevolt
Copy link

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?

@muhamedkapoevolt
Copy link

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!

Copy link

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!

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet