Skip to content

Commit

Permalink
add in missing FindEIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Jan 28, 2022
1 parent a073c3e commit e604544
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/service/ec2/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,31 @@ func FindEBSVolume(conn *ec2.EC2, input *ec2.DescribeVolumesInput) (*ec2.Volume,
return output[0], nil
}

func FindEIPs(conn *ec2.EC2, input *ec2.DescribeAddressesInput) ([]*ec2.Address, error) {
var addresses []*ec2.Address

output, err := conn.DescribeAddresses(input)

if tfawserr.ErrCodeEquals(err, ErrCodeInvalidAddressNotFound, ErrCodeInvalidAllocationIDNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

for _, v := range output.Addresses {
if v != nil {
addresses = append(addresses, v)
}
}

return addresses, nil
}

func FindHostByID(conn *ec2.EC2, id string) (*ec2.Host, error) {
input := &ec2.DescribeHostsInput{
HostIds: aws.StringSlice([]string{id}),
Expand Down

0 comments on commit e604544

Please sign in to comment.