terraform-aws-modules / terraform-aws-autoscaling

Terraform module to create AWS Auto Scaling resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws
Apache License 2.0
289 stars 553 forks source link

Destroy with empty state: Invalid index #215

Closed p24-max closed 1 year ago

p24-max commented 1 year ago

Description

terraform destroy fails when not all resources could be removed due to an error and the destroy command needs to be executed again. terraform destroy fails with this error:

╷
│ Error: Invalid index
│ 
│   on main.tf line 24, in locals:
│   24:   iam_instance_profile_arn  = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].arn : var.iam_instance_profile_arn
│     ├────────────────
│     │ aws_iam_instance_profile.this is empty tuple
│ 
│ The given key does not identify an element in this collection value: the
│ collection has no elements.
╵

Versions

bryantbiggs commented 1 year ago

This is a provider related issue and not a module issue:

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.