resource "aws_elastic_beanstalk_environment" "eb_env" {
id = "e-zfvjkxrhap"
name = "api-prod"
tags = {}
# (17 unchanged attributes hidden)
- setting {
- name = "InstanceTypes" -> null
- namespace = "aws:ec2:instances" -> null
- value = "t3.medium, t3.micro, t3.small" -> null
}
+ setting {
+ name = "DBSubnets"
+ namespace = "aws:ec2:vpc"
+ value = "subnet-071aa19a12d37195e,subnet-083bb9cec8b75cfcc"
}
+ setting {
+ name = "InstanceTypes"
+ namespace = "aws:ec2:instances"
+ value = "t3.medium,t3.micro,t3.small"
}
# (27 unchanged blocks hidden)
}
Variable declaration
eb_instance_types = ["t3.micro","t3.small","t3.medium"]
Why is elastic beanstalk always recreating elastic beanstalk without new changes?
Terraform config
setting {
namespace = "aws:ec2:instances"
name = "InstanceTypes"
value = join(",", sort(var.eb_instance_types))
resource = ""
}
The underlying Elastic Beanstalk API seems to be silently changing the value you set for "InstanceTypes" from "t3.medium,t3.micro,t3.small"
to "t3.medium, t3.micro, t3.small"
, which the hashicorp/aws
provider is incorrectly classifying as "drift" (changes outside of Terraform) rather than as a different way to write the same information.
Providers are typically supposed to include rules to detect situations where a remote API normalizes a value and returns it in a different way than how you wrote it, but the provider seems to be missing a rule for this situation. (You might wish to report a bug in the provider's GitHub repository about that.)
To work around the bug in the provider, you could try setting the value to match the normalized form that the API is returning, so that the AWS provider will not incorrectly notice a difference:
setting {
namespace = "aws:ec2:instances"
name = "InstanceTypes"
value = join(", ", sort(var.eb_instance_types))
resource = ""
}
Notice that there's now a space after the comma in the join
delimiter, which should produce a string matching the one that the remote API is returning.
This same general rule applies to any provider bug where a value gets normalized in some way that prevents your configuration from "converging" (the desired state described by the configuration matches the actual state of the remote system). If just changing the InstanceTypes
setting is insufficient to reach convergence then you should keep editing your configuration to match the -
(removed) entries in the plan until the configuration matches the exact values returned by the remote system.