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.84k stars 9.19k forks source link

[Bug]: Terraform state got updated even after the desired single change for eks resource is failed to apply #35575

Open prasad0414 opened 9 months ago

prasad0414 commented 9 months ago

Terraform Core Version

1.5.5

AWS Provider Version

5.30.0

Affected Resource(s)

resource aws_eks_cluster

I tried to upgrade the eks version from 1.25 to 1.26 but the operation failed due to insufficient IP addresses in the subnet, that's fine but, it also have updated the state file with 1.26 as if the operation was successful (apply failed actually) due to this, when we fixed the IP address issue and retried the upgrade it simply says infrastructure matches the desired configuration during plan phase and apply phase is getting skipped, thus creates the issue when installing appropriate add-ons in the clusters further.

Expected Behavior

Terraform shouldn't have updated the state file since the only single desired operation got failed (verified from the AWS console)

Actual Behavior

Terraform has updated the state file with 1.26 as if the operation was successful (apply failed actually)

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

# provisions eks luster
resource "aws_eks_cluster" "eksCluster" {
  name     = "dma-${var.installId}"
  role_arn = var.masterRoleArn
  version = var.kubernetesVersion
  vpc_config {
    subnet_ids = split(",", var.productSubnetIds)
    security_group_ids = split(",", var.masterSG)
    endpoint_private_access = true
    endpoint_public_access = local.isGov
# TODO:check how endpoint_public_access working for gov cloud
  }
  enabled_cluster_log_types = local.logTypes
  tags = {
    "Product" = var.productId
    "Service" = "${var.productId}:eks"
    "Team" = var.team
    "Owner" = var.emailId
    "dma.infor.com/installId" = var.installId
    "automationProvider" = var.automationProvider
  }
}

Steps to Reproduce

NA

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 9 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

bryantbiggs commented 2 months ago

I don't follow - if the upgrade failed then that would mean the control plane is on 1.25, correct? so Terraform would pick up the diff if the statefile shows 1.26

perhaps the statefile wasn't updated and both the statefile and the control plane are on 1.25?