From f0c23cce7935749056bd8933eee7dd331f135415 Mon Sep 17 00:00:00 2001 From: TangBin Date: Thu, 25 Oct 2018 19:39:34 +0800 Subject: [PATCH] bugfix --- pkg/util/aws/eip.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/util/aws/eip.go b/pkg/util/aws/eip.go index ac81461d5d..7e41d8ee9f 100644 --- a/pkg/util/aws/eip.go +++ b/pkg/util/aws/eip.go @@ -1,6 +1,7 @@ package aws import ( + "fmt" "github.com/aws/aws-sdk-go/service/ec2" "yunion.io/x/jsonutils" "yunion.io/x/log" @@ -221,6 +222,10 @@ func (self *SRegion) DissociateEip(eipId string, instanceId string) error { return nil } + if eip.InstanceId != instanceId { + return fmt.Errorf("eip %s associate with another instance %s", eipId, eip.InstanceId) + } + params := &ec2.DisassociateAddressInput{} params.SetAssociationId(eip.AssociationId) _, err = self.ec2Client.DisassociateAddress(params)