func (c *awsclient) RemoveInterface(interfaceIDs []string) error {
	client, err := c.newEC2()
	if err != nil {
		return err
	}

	for _, interfaceID := range interfaceIDs {
		// TODO: check if there is any other interface on this namespace?

		// We need the interface AttachmentId to detach
		interfaceDescription, err := c.describeNetworkInterface(interfaceID)
		if err != nil {
			return err
		}

		detachInterfaceInput := &ec2.DetachNetworkInterfaceInput{
			AttachmentId: interfaceDescription.Attachment.AttachmentId,
			DryRun:       aws.Bool(false),
			Force:        aws.Bool(false),
		}

		// Detach the networkinterface
		_, err = client.DetachNetworkInterface(detachInterfaceInput)
		if err != nil {
			fmt.Printf("Error occurced when trying to detach %v interface, use --force to override this check", interfaceID)
			return err
		}

		// Wait for the interface to be removed
		if err := c.waitUtilInterfaceDetaches(interfaceID); err != nil {
			return err
		}

		// Even after the interface detaches, you cannot delete right away
		time.Sleep(interfacePostDetachSettleTime)

		// Now we can safely remove the interface
		if err := c.deleteInterface(interfaceID); err != nil {
			return err
		}
	}
	return nil
}
// RemoveInterface gracefull shutdown and removal of interfaces
// Simply detach the interface, wait for it to come down and then
// removes.
RemoveInterface gracefull shutdown and removal of interfaces
Simply detach the interface, wait for it to come down and then
removes.
// RemoveInterface gracefull shutdown and removal of interfaces // Simply detach the interface wait for it to come down and then // removes .
func (c *awsclient) RemoveInterface(interfaceIDs []string) error {
	client, err := c.newEC2()
	if err != nil {
		return err
	}
	for _, interfaceID := range interfaceIDs {
		interfaceDescription, err := c.describeNetworkInterface(interfaceID)
		if err != nil {
			return err
		}
		detachInterfaceInput := &ec2.DetachNetworkInterfaceInput{
			AttachmentId: interfaceDescription.Attachment.AttachmentId,
			DryRun:       aws.Bool(false),
			Force:        aws.Bool(false),
		}
		_, err = client.DetachNetworkInterface(detachInterfaceInput)
		if err != nil {
			fmt.Printf("Error occurced when trying to detach %v interface, use --force to override this check", interfaceID)
			return err
		}
		if err := c.waitUtilInterfaceDetaches(interfaceID); err != nil {
			return err
		}
		time.Sleep(interfacePostDetachSettleTime)
		if err := c.deleteInterface(interfaceID); err != nil {
			return err
		}
	}
	return nil
}
func ( c * awsclient ) RemoveInterface ( interfaceIDs [ ] string ) error { client , err := c . newEC2 ( ) if err != nil { return err } for _ , interfaceID := range interfaceIDs { interfaceDescription , err := c . describeNetworkInterface ( interfaceID ) if err != nil { return err } detachInterfaceInput := & ec2 . DetachNetworkInterfaceInput { AttachmentId : interfaceDescription . Attachment . AttachmentId , DryRun : aws . Bool ( false ) , Force : aws . Bool ( false ) , } _ , err = client . DetachNetworkInterface ( detachInterfaceInput ) if err != nil { fmt . Printf ( " " , interfaceID ) return err } if err := c . waitUtilInterfaceDetaches ( interfaceID ) ; err != nil { return err } time . Sleep ( interfacePostDetachSettleTime ) if err := c . deleteInterface ( interfaceID ) ; err != nil { return err } } return nil }
RemoveInterface gracefull shutdown and removal of interfaces
Simply detach the interface, wait for it to come down and then
removes.
RemoveInterface gracefull shutdown and removal of interfaces Simply detach the interface wait for it to come down and then removes .
// TODO: check if there is any other interface on this namespace? // We need the interface AttachmentId to detach // Detach the networkinterface // Wait for the interface to be removed // Even after the interface detaches, you cannot delete right away // Now we can safely remove the interface