From cccfa0785f12b4ece4526de91a70b415c9e30cae Mon Sep 17 00:00:00 2001 From: Waiariki Koia Date: Fri, 8 Jan 2021 09:16:32 +0000 Subject: [PATCH] Only change the identifier, as changing the name results in new resource being created --- lib/terrafying/components/dynamicset.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/terrafying/components/dynamicset.rb b/lib/terrafying/components/dynamicset.rb index 7d18608..097bec0 100644 --- a/lib/terrafying/components/dynamicset.rb +++ b/lib/terrafying/components/dynamicset.rb @@ -169,13 +169,14 @@ def attach_load_balancer(load_balancer) def autoscale_on_load_balancer(load_balancer, target_value:, disable_scale_in:) load_balancer.targets.each.with_index do |target, i| - policy_name = "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1') + policy_ident = "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1') + policy_name = "#{load_balancer.name}-#{@name}-#{i}" lb_arn = load_balancer.id.to_s.gsub(/id/, 'arn_suffix') tg_arn = target.target_group.to_s.gsub(/id/, 'arn_suffix') listener = "aws_lb_listener.#{target.listener.to_s.split('.')[1]}" - autoscaling_attachment = "aws_autoscaling_attachment.#{policy_name}" + autoscaling_attachment = "aws_autoscaling_attachment.#{policy_ident}" - resource :aws_autoscaling_policy, policy_name, + resource :aws_autoscaling_policy, policy_ident, name: policy_name, autoscaling_group_name: @asg, policy_type: 'TargetTrackingScaling',