hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[Bug]: Provider produced inconsistent final plan #38647

Open adept-mayank opened 1 month ago

adept-mayank commented 1 month ago

Terraform Core Version

1.1.6

AWS Provider Version

5.60.0

Affected Resource(s)

Network Load Balancer

Expected Behavior

Internet facing NLB will create with 2 EIP in two subnets

Actual Behavior

Unable to create public NLB.

Relevant Error/Panic Output Snippet

│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for aws_lb.example to include new values learned so
│ far during apply, provider "registry.terraform.io/hashicorp/aws" produced
│ an invalid new value for .subnet_mapping: planned set element
│ cty.ObjectVal(map[string]cty.Value{"allocation_id":cty.StringVal("eipalloc-041fe95ff4a534d11"),
│ "ipv6_address":cty.NullVal(cty.String), "outpost_id":cty.StringVal(""),
│ "private_ipv4_address":cty.NullVal(cty.String),
│ "subnet_id":cty.StringVal("subnet-0a5f9b78f18d68949")}) does not correlate
│ with any element in actual.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for aws_lb.example to include new values learned so
│ far during apply, provider "registry.terraform.io/hashicorp/aws" produced
│ an invalid new value for .subnet_mapping: block set length changed from 2
│ to 3.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Terraform Configuration Files

##nlb.tf
resource "aws_lb" "public_nlb" {
  name                      = "${local.pub_nlb_naming}"
  load_balancer_type        = "network"

  subnet_mapping {
    subnet_id     = data.aws_cloudformation_export.publicsubnetA1.value    
    allocation_id = aws_eip.eipp.id
  }

  subnet_mapping {
    subnet_id     = data.aws_cloudformation_export.publicsubnetB1.value 
  }

  enable_cross_zone_load_balancing = true
  enable_deletion_protection       = false
  security_groups                  = [aws_security_group.public_lb.id]
  tags = merge(
      {
         "Name" = "${local.pub_nlb_naming}"
       },
       local.tags,
     )
}  

##data.tf
data "aws_cloudformation_export" "publicsubnetA1" {
  name = "${var.appstack}-PublicSubnetAZaId"
}

data "aws_cloudformation_export" "publicsubnetB1" {
  name = "${var.appstack}-PublicSubnetAZbId"
}

##local.tf
pub_nlb_naming = "elb-testing-pubnlb"

Steps to Reproduce

Create three files.

  1. locals.tf
  2. data.tf
  3. lb.tf

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue