Skip to content

aws_vpc_security_group_egress_rule fails plan with: Error: failed to decode identity: unsupported attribute "account_id". #44316

Description

@nairb774

Terraform and AWS Provider Version

Failing configuration:

$ terraform --version
Terraform v1.13.2
on linux_amd64
+ provider registry.terraform.io/datadog/datadog v3.73.0
+ provider registry.terraform.io/hashicorp/aws v6.13.0
+ provider registry.terraform.io/hashicorp/random v3.7.2
+ provider registry.terraform.io/hashicorp/tfe v0.68.2
+ provider registry.terraform.io/hashicorp/time v0.13.1
+ provider registry.terraform.io/hashicorp/tls v4.1.0
+ provider registry.terraform.io/integrations/github v6.6.0
+ provider registry.terraform.io/nairb774/flipflop v0.2.0
+ provider registry.terraform.io/tailscale/tailscale v0.21.1

---

Working configuration:

$ terraform --version
Terraform v1.12.2
on linux_amd64
+ provider registry.terraform.io/datadog/datadog v3.73.0
+ provider registry.terraform.io/hashicorp/aws v6.13.0
+ provider registry.terraform.io/hashicorp/random v3.7.2
+ provider registry.terraform.io/hashicorp/tfe v0.68.2
+ provider registry.terraform.io/hashicorp/time v0.13.1
+ provider registry.terraform.io/hashicorp/tls v4.1.0
+ provider registry.terraform.io/integrations/github v6.6.0
+ provider registry.terraform.io/nairb774/flipflop v0.2.0
+ provider registry.terraform.io/tailscale/tailscale v0.21.1

---

Only difference is updating Terraform from 1.12.2 to 1.13.2.

Affected Resource(s) or Data Source(s)

  • aws_vpc_security_group_egress_rule
  • aws_vpc_security_group_ingress_rule

Expected Behavior

Upgrading from Terraform 1.12.2 to 1.13.2 should work without issue.

Actual Behavior

Unable to upgrade to using Terraform from 1.12.2 to 1.13.2 due to what looks to be a bug in the AWS provider.

Relevant Error/Panic Output

Error: failed to decode identity: unsupported attribute "account_id". This is most likely a bug in the Provider, providers must not change the identity schema without updating the identity schema version
Error: failed to decode identity: unsupported attribute "account_id". This is most likely a bug in the Provider, providers must not change the identity schema without updating the identity schema version
Warning: Failed to decode resource from state
Error decoding "aws_vpc_security_group_egress_rule.rule[\"port:5432\"]" from prior state: failed to decode identity: unsupported attribute "account_id". This is most likely a bug in the Provider, providers must not change the identity schema without updating the identity schema version
Warning: Failed to decode resource from state
Error decoding "aws_vpc_security_group_ingress_rule.rule[\"port:5432\"]" from prior state: failed to decode identity: unsupported attribute "account_id". This is most likely a bug in the Provider, providers must not change the identity schema without updating the identity schema version

Sample Terraform Configuration

Click to expand configuration

This is a simplified version of the code found in our workspace. I attempted to preserve as much structure as possible while at the same time disconnecting it from some internals.

provider "aws" {
  region = "us-east-1"
}

locals {
  ports = { for port in [var.port] : "port:${port}" => port }
}

resource "aws_vpc_security_group_egress_rule" "rule" {
  for_each = local.ports

  description                  = var.description
  security_group_id            = var.egress_security_group_id
  referenced_security_group_id = var.ingress_security_group_id

  ip_protocol = var.ip_protocol
  from_port   = each.value
  to_port     = each.value
}

resource "aws_vpc_security_group_ingress_rule" "rule" {
  for_each = local.ports

  description                  = var.description
  security_group_id            = var.ingress_security_group_id
  referenced_security_group_id = var.egress_security_group_id

  ip_protocol = var.ip_protocol
  from_port   = each.value
  to_port     = each.value
}

Steps to Reproduce

We updated to aws 6.13.0 a few days ago. Now attempting to upgrade Terraform to the 1.13 release cycle seems to be blocked.

I see #44198 was added in the 6.13.0 aws provider release, and it looks to be suspiciously related.

Looking in the state file for the implicated resources (all egress/ingress rules in the workspace) I see things like the following:

{
  "mode": "managed",
  "type": "aws_vpc_security_group_egress_rule",
  "name": "a_rule",
  "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
  "instances": [
    {
      "schema_version": 0,
      "attributes": {
        "arn": "arn:aws:ec2:us-east-1:123456789012:security-group-rule/sgr-00112233445566778",
        "cidr_ipv4": null,
        "cidr_ipv6": "::/0",
        "description": "",
        "from_port": null,
        "id": "sgr-00112233445566778",
        "ip_protocol": "-1",
        "prefix_list_id": null,
        "referenced_security_group_id": null,
        "region": "us-east-1",
        "security_group_id": "sg-aabbccddeeff00112",
        "security_group_rule_id": "sgr-00112233445566778",
        "tags": null,
        "tags_all": {
          "zzz": "zzz"
        },
        "to_port": null
      },
      "sensitive_attributes": [],
      "identity_schema_version": 0,
      "identity": {
        "account_id": "123456789012",
        "id": "sgr-00112233445566778",
        "region": "us-east-1"
      },
      "dependencies": [
        "aws_security_group.a_group",
        "aws_vpc.vpc"
      ]
    }
  ]
}

We've not set any resource level account/region/provider settings. Additionally, attempting a state refresh, or a plan/apply cycle doesn't clear the error.

Debug Logging

GenAI / LLM Assisted Development

n/a

Important Facts and References

No response

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/vpcIssues and PRs that pertain to the vpc service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions