Skip to content

Error: Unexpected Identity Change: During the read operation, the Terraform Provider unexpectedly returned a different identity then the previously stored one. #44295

@JonnoN

Description

@JonnoN

Terraform and AWS Provider Version

Terraform v1.13.2
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v6.13.0

Affected Resource(s) or Data Source(s)

aws_security_group

Expected Behavior

no error

Actual Behavior

errors and exits

Relevant Error/Panic Output

│ 
│ This is always a problem with the provider and should be reported to the provider developer.
│ 
│ Current Identity: cty.ObjectVal(map[string]cty.Value{"account_id":cty.NullVal(cty.String), "id":cty.NullVal(cty.String), "region":cty.NullVal(cty.String)})
│ 
│ New Identity: cty.ObjectVal(map[string]cty.Value{"account_id":cty.StringVal("REDACTED"), "id":cty.StringVal("sg-REDACTED"), "region":cty.StringVal("us-east-1")})
│ 
│   with aws_security_group.va_rds_sg,
│   on main-va.tf line 52, in resource "aws_security_group" "va_rds_sg":
│   52: resource "aws_security_group" "va_rds_sg" {
│ 

Sample Terraform Configuration

Click to expand configuration
State is stored in backend "s3" dynamo_table and bucket.

resource "aws_rds_cluster_parameter_group" "va_settings" {
  provider    = aws.va
  name        = "${var.va_cluster_identifier}-postgres15-cluster-pg"
  family      = "aurora-postgresql15"
  description = "Postgres 15 cluster parameter group"

  parameter {
    name  = "max_connections"
    value = 1800
  }
}

Steps to Reproduce

First 'terraform apply' errored which seems to have broken the state. I have fixed the errors with the PG and SG, but the terraform error persists.

This was the initial error:

│ 
│   with aws_rds_cluster_parameter_group.va_settings,
│   on main-va.tf line 4, in resource "aws_rds_cluster_parameter_group" "va_settings":
│    4: resource "aws_rds_cluster_parameter_group" "va_settings" {
│ 
╵
╷
│ Error: updating Security Group (sg-REDACTED) ingress rules: authorizing Security Group (ingress) rules: operation error EC2: AuthorizeSecurityGroupIngress, https response error StatusCode: 400, RequestID: x, api error InvalidParameterValue: The same permission must not appear multiple times
│ 
│   with aws_security_group.va_rds_sg,
│   on main-va.tf line 49, in resource "aws_security_group" "va_rds_sg":
│   49: resource "aws_security_group" "va_rds_sg" {
│ ```

### Debug Logging

<details open>
<summary>Click to expand log output</summary>

```console

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.resource-identityPertains to resource identity.service/rdsIssues and PRs that pertain to the rds service.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