aws_autoscaling_group failed when 'for' provided in vpc_zone_identifier #10501
Closed as not planned
Description
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
Terraform v0.12.10
- provider.aws v2.32.0
Affected Resource(s)
aws_autoscaling_group
Terraform Configuration Files
Main section part example:
provider "aws" {
version = "2.32.0"
}
module "base_vpc" {
source = "../modules/base_vpc"
autoscaling_hosts = [
{
name = "host_1"
instance_type = "t3.medium"
availability_zones = ["eu-west-1a", "eu-west-1b"]
desired_capacity = 0
min_size = 0
max_size = 1
},
{
name = "host_2"
instance_type = "t3.small"
availability_zones = ["eu-west-1b"]
desired_capacity = 0
min_size = 0
max_size = 1
},
]
}
Module part example:
resource "aws_autoscaling_group" "autoscaling" {
count = length(var.autoscaling_hosts)
depends_on = [aws_route.private, aws_launch_template.autoscaling]
name = "${lookup(var.autoscaling_hosts[count.index], "name")}-${var.env}"
availability_zones = lookup(var.autoscaling_hosts[count.index], "availability_zones")
desired_capacity = lookup(var.autoscaling_hosts[count.index], "desired_capacity")
min_size = lookup(var.autoscaling_hosts[count.index], "min_size")
max_size = lookup(var.autoscaling_hosts[count.index], "max_size")
launch_template {
id = element(aws_launch_template.autoscaling.*.id, count.index)
version = "$Latest"
}
vpc_zone_identifier = [for zone in lookup(var.autoscaling_hosts[count.index], "availability_zones") : element(aws_subnet.private.*.id, index(lookup(var.autoscaling_hosts[count.index], "availability_zones"), zone))]
}
Debug Output
2019/10/14 16:41:59 [WARN] Provider "aws" produced an invalid plan for module.base_vpc.aws_autoscaling_group.autoscaling[0], but we are tolerating it because it is using the legacy plugin SDK.
The following problems may be the cause of any confusing errors from downstream operations:
- .force_delete: planned value cty.False does not match config value cty.NullVal(cty.Bool)
- .protect_from_scale_in: planned value cty.False does not match config value cty.NullVal(cty.Bool)
- .availability_zones: planned value cty.UnknownVal(cty.Set(cty.String)) does not match config value cty.SetVal([]cty.Value{cty.StringVal("eu-west-1a"), cty.StringVal("eu-west-1b")})
- .wait_for_capacity_timeout: planned value cty.StringVal("10m") does not match config value cty.NullVal(cty.String)
- .health_check_grace_period: planned value cty.NumberIntVal(300) does not match config value cty.NullVal(cty.Number)
- .metrics_granularity: planned value cty.StringVal("1Minute") does not match config value cty.NullVal(cty.String)
Panic Output
Expected Behavior
Resource must be created when terraform apply provided
Actual Behavior
When I run 'terraform apply' at first time, I see an error like in gist above. When I run 'terraform apply' at second time, aws_autoscaling_group resource is creating successfully.
Steps to Reproduce
terraform apply
Important Factoids
References
- #0000