Skip to content

Commit ff101e6

Browse files
helvaliusJan NonnenJan Nonnen
authored
Terraform 0.12 setting fix (#132)
* further fixes for #114 * spot instance variables and dynamic variables where not covered * sorting for securitygroups was not enough those two issues resulted in still having terraform plan showing changes even if no changes were present. * change SpotMaxPrice setting to be dynamic * formatting changes ran terraform fmt to reformat changes * Revert "formatting changes" This reverts commit 1b2f723. * redo formatting changes due to wrong email Co-authored-by: Jan Nonnen <helvalous@gmail.com> Co-authored-by: Jan Nonnen <helvalius@gmail.com>
1 parent b088b4c commit ff101e6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

main.tf

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ resource "aws_elastic_beanstalk_environment" "default" {
546546
setting {
547547
namespace = "aws:autoscaling:launchconfiguration"
548548
name = "SecurityGroups"
549-
value = join(",", compact(concat([aws_security_group.default.id], sort(var.additional_security_groups))))
549+
value = join(",", compact(sort(concat([aws_security_group.default.id], var.additional_security_groups))))
550550
resource = ""
551551
}
552552

@@ -659,25 +659,24 @@ resource "aws_elastic_beanstalk_environment" "default" {
659659
namespace = "aws:ec2:instances"
660660
name = "EnableSpot"
661661
value = var.enable_spot_instances ? "true" : "false"
662+
resource = ""
662663
}
663664

664665
setting {
665666
namespace = "aws:ec2:instances"
666667
name = "SpotFleetOnDemandBase"
667668
value = var.spot_fleet_on_demand_base
669+
resource = ""
668670
}
669671

670672
setting {
671673
namespace = "aws:ec2:instances"
672674
name = "SpotFleetOnDemandAboveBasePercentage"
673675
value = var.spot_fleet_on_demand_above_base_percentage == -1 ? (var.environment_type == "LoadBalanced" ? 70 : 0) : var.spot_fleet_on_demand_above_base_percentage
676+
resource = ""
674677
}
675678

676-
setting {
677-
namespace = "aws:ec2:instances"
678-
name = "SpotMaxPrice"
679-
value = var.spot_max_price == -1 ? "null" : var.spot_max_price
680-
}
679+
681680

682681
setting {
683682
namespace = "aws:autoscaling:launchconfiguration"
@@ -706,6 +705,7 @@ resource "aws_elastic_beanstalk_environment" "default" {
706705
namespace = "aws:autoscaling:launchconfiguration"
707706
name = "ImageId"
708707
value = setting.value
708+
resource = ""
709709
}
710710
}
711711

@@ -872,6 +872,17 @@ resource "aws_elastic_beanstalk_environment" "default" {
872872
}
873873
}
874874

875+
// dynamic needed as "spot max price" should only have a value if it is defined.
876+
dynamic "setting" {
877+
for_each = var.spot_max_price == -1 ? [] : [var.spot_max_price]
878+
content {
879+
namespace = "aws:ec2:instances"
880+
name = "SpotMaxPrice"
881+
value = var.spot_max_price
882+
resource = ""
883+
}
884+
}
885+
875886
// Add environment variables if provided
876887
dynamic "setting" {
877888
for_each = var.env_vars

0 commit comments

Comments
 (0)