From f179215a134241929ba5299cb16d2de272f7938c Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Sun, 30 Jul 2023 10:19:06 -0500 Subject: [PATCH] Fix WarmPool with --target direct --- .../fi/cloudup/awstasks/autoscalinggroup.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go index 29a4dc8a85bad..52e7a1fadcc7e 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go @@ -110,6 +110,37 @@ func (e *AutoscalingGroup) CompareWithID() *string { return e.Name } +// Track dependencies here to explicitly ignore WarmPool +// because the WarmPool should be created after the ASG, not the other way around. +// The WarmPool struct field is only used for RenderTerraform. +func (e *AutoscalingGroup) GetDependencies(tasks map[string]fi.CloudupTask) []fi.CloudupTask { + var deps []fi.CloudupTask + + if e.LoadBalancers != nil { + for _, lb := range e.LoadBalancers { + deps = append(deps, lb) + } + } + + if e.TargetGroups != nil { + for _, tg := range e.TargetGroups { + deps = append(deps, tg) + } + } + + if e.Subnets != nil { + for _, subnet := range e.Subnets { + deps = append(deps, subnet) + } + } + + if e.LaunchTemplate != nil { + deps = append(deps, e.LaunchTemplate) + } + + return deps +} + // Find is used to discover the ASG in the cloud provider func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error) { cloud := c.T.Cloud.(awsup.AWSCloud)