terraform-provider-aws: Provider produced inconsistent final plan
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
- 0.12.0-beta1
- provider.aws: version = “~> 1.60”
- provider.null: version = “~> 2.1”
Affected Resource(s)
- aws_autoscaling_group
Terraform Configuration Files
This is part of a bigger module, I will try to copy out all the relevant parts
resource "aws_autoscaling_group" "elb" {
count = var.lb_type=="elb" ? 1 : 0
lifecycle {
create_before_destroy = true
}
availability_zones = local.azs
name = aws_launch_configuration.launch_configuration.name
min_size = lookup(var.asg_properties,"min_size", 1)
max_size = lookup(var.asg_properties,"max_size", 1)
min_elb_capacity = lookup(var.asg_properties,"min_elb_capacity", 1)
health_check_grace_period = lookup(var.asg_properties,"health_check_grace_period", 300)
desired_capacity = lookup(var.asg_properties,"desired_capacity", 1)
health_check_type = lookup(var.asg_properties,"health_check_type", "ELB")
launch_configuration = aws_launch_configuration.launch_configuration.name
vpc_zone_identifier = split(",",local.private_subnets)
load_balancers = [aws_elb.elb[0].id]
wait_for_capacity_timeout = lookup(var.asg_properties,"wait_for_capacity_timeout", "300s")
dynamic "tag" {
for_each = local.tags
content {
propagate_at_launch = true
key = element(keys(tag),0)
value = element(values(tag),0)
}
}
}
locals {
subnets_choice = split(",",(var.lb_internal ? local.private_subnets : local.public_subnets))
eip_choice = length(var.nlb_elastic_ip_allocation_id) == 0 ? aws_eip.nlb.*.allocation_id : var.nlb_elastic_ip_allocation_id
}
locals {
public_subnets = join(",",data.terraform_remote_state.network.outputs["subnets-public.subnet_id"])
private_subnets = join(",",data.terraform_remote_state.network.outputs["subnets-private.subnet_id"])
database_subnets = join(",",data.terraform_remote_state.network.outputs["subnets-database.subnet_id"])
tags = merge(
{
"Name"= var.application_name,
"Region" = var.region,
"Deployment_folder_in_repo" = replace(path.root, "/^(.*)(/.*/platform/apps/.*)/", "$2"),
"Deployment_time_UTC" = timestamp(),
},
var.unspecific_tags)
azs = slice(data.aws_availability_zones.available.names,0,var.amount_azs)
}
variable "asg_properties" {
description = "Properties map for the autoscaling group. If a map is provided with keys missing, the following defaults will be used. For explanation of the keys, reference terraform documentation for aws_auto_scaling_group"
type = map(string)
default = {
min_size = "1"
max_size = "1"
min_elb_capacity = "1"
health_check_grace_period = "300"
desired_capacity = "1"
health_check_type = "ELB"
wait_for_capacity_timeout = "300"
}
}
variable "unspecific_tags" {
description = "Tags that are feeded to the module for more extensive tagging of resources. They are unspecific to the deployment and defined environment-wide in the tfvars for this deployment"
default = {}
type = map(string)
}
variable "build_uri" {
description = "Build_uri of the jenkins-job. Is feeded to the module by jenkins"
default = ""
type = string
}
variable "lb_type" {
description = "Important. Can be strings of value 'elb','alb','nlb' or 'none'. Decides, what type of loadbalancer will be created. The variables specific to ELB or ALB/NLB deployment must be provided, or the deployment will fail"
default = "elb"
type = string
}
variable "lb_internal" {
description = "Important. Can be true or false. Toggles, whether loadbalancers are supposed to be placed in public or private subnets. For 'lb_type=none', it decides whether the instances of the ASG are placed in public or private subnets"
default = true
type = bool
}
Debug Output
Panic Output
Expected Behavior
the following block:
dynamic "tag" {
for_each = local.tags
content {
propagate_at_launch = true
key = element(keys(tag),0)
value = element(values(tag),0)
}
}
Should have iterated through each key-value-pair of the local.tags map and create a tag-block for each one, including the “propagate_at_launch=true” key-value-pair.
Actual Behavior
10:49:57 Error: Provider produced inconsistent final plan 10:49:57 10:49:57 When expanding the plan for module.application.aws_autoscaling_group.elb[0] to 10:49:57 include new values learned so far during apply, provider “aws” produced an 10:49:57 invalid new value for .tag: block set length changed from 1 to 12. 10:49:57 10:49:57 This is a bug in the provider, which should be reported in the provider’s own 10:49:57 issue tracker.
Steps to Reproduce
terraform apply
Important Factoids
Am I misunderstanding maps, when I assumed they would be iterable per each key-value-pair?
References
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 44
- Comments: 17 (2 by maintainers)
Hi folks 👋 The original issue reported here should be resolved as of Terraform CLI 0.12.28 and Terraform AWS Provider 2.70.0 (potentially much sooner in both). If you are still experiencing issues with
aws_autoscaling_groupresourcetagsargument handling on those versions or later, please file a new bug report issue including all the details requested in the issue template and we can take a fresh look. Thanks.This is still relevant with aws provider version 2.11 and terraform 0.12.0-rc1. Can I assist by providing any additional information?
Some additional information, the culprit in my case is the filter I’m applying to
var.target_groups:Using the var.target_groups variable directly works as expected. I was in need of that filter for modularization purposes but I’m reworking my pipeline to be less modularized in the meantime.
Hi, I’m experiencing a similar issue with dynamic load balancers being linked to an ECS Service:
This is inside sub-module -
var.target_groupsis populated by the parent module with either one or multiple target groups.The initial plan shows a single load_balancer block with unknown values, and the apply fails with:
Any help would be greatly appreciated 😃
Running into the same issue with aws provider 2.14.0 and terraform 0.12.1. @theTranqu, did you ever find a workaround?
@apparentlymart, should’ve https://github.com/hashicorp/terraform/pull/21193 fixed this issue here as well?