Open
Description
Terraform and AWS Provider Version
Terraform AWS Provider v5.84.0
Terraform v1.10.5
Affected Resource(s) or Data Source(s)
aws_elastic_beanstalk_environment
Expected Behavior
If settings
with the same namespace, name, and value exist in both the state and configuration, they should be recognized as identical regardless of resource attribute differences.
Actual Behavior
Every terraform plan
shows settings being removed and re-added even when they haven't changed, for example:
- setting {
- name = "ServiceRole" -> null
- namespace = "aws:elasticbeanstalk:environment" -> null
- value = "aws-elasticbeanstalk-service-role" -> null
# (1 unchanged attribute hidden)
}
+ setting {
+ name = "ServiceRole"
+ namespace = "aws:elasticbeanstalk:environment"
+ resource = "AWSEBV2LoadBalancer"
+ value = "aws-elasticbeanstalk-service-role"
}
Relevant Error/Panic Output
Sample Terraform Configuration
Click to expand configuration
Steps to Reproduce
- Create an Elastic Beanstalk environment with settings that include resource attributes
- Run
terraform apply
to create the environment - Run
terraform plan
without changing any settings - Observe the plan shows settings being removed and re-added
Debug Logging
Click to expand log output
GenAI / LLM Assisted Development
n/a
Important Facts and References
The issue likely stems from how the AWS provider performs comparison of settings in the diff process.
Provider-Level Fix
-
Modify the resource comparison logic in
aws_elastic_beanstalk_environment
resource:// In the resourceElasticBeanstalkEnvironmentSettingHash function: // Currently likely using something like: hash := fmt.Sprintf("%s:%s:%s:%s", setting.Namespace, setting.Name, setting.Value, setting.Resource) // Change to ignore resource attribute in comparison: hash := fmt.Sprintf("%s:%s:%s", setting.Namespace, setting.Name, setting.Value)
-
Add normalization for resource attributes during plan/apply phases:
- Maintain a mapping of namespace → expected resource attribute
- When applying settings, use the provider's canonical resource attribute for each namespace/name combination
- This preserves the attribute for AWS API calls while preventing unnecessary diffs
-
Add an option to control comparison behavior:
resource "aws_elastic_beanstalk_environment" "example" { name = "example-env" # ... setting_comparison_mode = "exclude_resource_attribute" # Default: "include_all" }
References
reported issue back in 2016
Would you like to implement a fix?
Sure