Skip to content

Commit b9df38f

Browse files
committed
Make use of VPC ID from state
1 parent fcd7da6 commit b9df38f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

pkg/controller/infrastructure/infraflow/reconcile.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,18 @@ func (c *FlowContext) ensureManagedVpc(ctx context.Context) error {
244244

245245
func (c *FlowContext) ensureVpcIPv6CidrBlock(ctx context.Context) error {
246246
if (c.config.DualStack != nil && c.config.DualStack.Enabled) || isIPv6(c.getIpFamilies()) {
247-
current, err := FindExisting(ctx, c.state.Get(IdentifierVPC), c.commonTags,
248-
c.client.GetVpc, c.client.FindVpcsByTags)
249-
if err != nil {
250-
return err
247+
vpcID := ptr.Deref(c.state.Get(IdentifierVPC), "")
248+
if vpcID == "" {
249+
current, err := FindExisting(ctx, nil, c.commonTags, c.client.GetVpc, c.client.FindVpcsByTags)
250+
if err != nil {
251+
return err
252+
}
253+
if current == nil || current.VpcId == "" {
254+
return fmt.Errorf("cannot find VPC id")
255+
}
256+
vpcID = current.VpcId
251257
}
252-
ipv6CidrBlock, err := c.client.WaitForIPv6Cidr(ctx, current.VpcId)
258+
ipv6CidrBlock, err := c.client.WaitForIPv6Cidr(ctx, vpcID)
253259
if err != nil {
254260
return err
255261
}

0 commit comments

Comments
 (0)