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.8k stars 9.15k forks source link

[Bug]: Root resource was present, but now absent #34657

Open pnikolaou82 opened 10 months ago

pnikolaou82 commented 10 months ago

Terraform Core Version

0.12.0

AWS Provider Version

5.27.0

Affected Resource(s)

aws_spot_instance_request, aws_iam_policy_attachment.policy_attachment2

Expected Behavior

Attach the Managed IAM Policy to the spot instance

Actual Behavior

│ Error: Provider produced inconsistent result after apply │ │ When applying changes to aws_iam_policy_attachment.policy_attachment2, │ provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an │ unexpected new value: Root resource was present, but now absent. │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to aws_iam_policy_attachment.policy_attachment, │ provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an │ unexpected new value: Root resource was present, but now absent. │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_spot_instance_request" "node" { for_each = { for vms in var.nodes : "${vms.name}" => vms if vms.spot_instance == true } ami = data.aws_ami.ubuntu.id instance_type = each.value["instance_type"] vpc_security_group_ids = [aws_security_group.internal.id] subnet_id = aws_subnet.private[each.value.availability_zone].id user_data = data.cloudinit_config.cloudinit[0].rendered

root_block_device { volume_size = each.value["volume_size"] delete_on_termination = "true" }

spot_price = each.value["spot_price"] wait_for_fulfillment = true spot_type = "one-time" tags = { "Name" = "${var.k8s_cluster_name}-${each.value["name"]}", "kubernetes.io/cluster/${var.k8s_cluster_name}" = "member", "Role" = "node" }

iam_instance_profile = aws_iam_instance_profile.kube-node.id }

Steps to Reproduce

Create an AWS aws_spot_instance_request with the provided code

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No, i wouldnt' like to implement a fix

github-actions[bot] commented 10 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

dosaki commented 5 months ago

Hello!

Is there any movement on this?

I'm having the same issue.

Error: Provider produced inconsistent result after apply

When applying changes to
module.configure_lambda["devices"].aws_iam_policy_attachment.s3_policy_attachment,
provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an
unexpected new value: Root object was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

That relevant resources looks like this:

resource "aws_iam_role" "iam_for_lambda" {
  name = "${var.lambda_name}-${var.env}"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_iam_policy_attachment" "s3_policy_attachment" {
  name       = "s3-policy-attachment"
  policy_arn = var.s3_policy_arn
  roles      = [aws_iam_role.iam_for_lambda.name]
}