cloudyr/aws.ec2

API not associating Elastic IPs with allocation ID for VPC

Opened this issue · 3 comments

Working off the github version of clodyr ec2 API.

Based on the documentation the allocate_ip(domain="vpc") should produce an allocationId I can use to deallocate but it does not:

> ip.1 = aws.ec2::allocate_ip(domain="vpc")
> ip.1
> ip.1
$publicIp
[1] "11.22.33.444"

$domain
[1] "vpc"

attr(,"class")
[1] "ec2_ip"
attr(,"requestId")           #>>>>>>>>>>>>>>> NO ALLOCATION ID TO USE FOR RELEASE 
[1] "xxxxxxx-yyyy-aaaa-bbbb-cccccccccc"

The issue is easy to see from the code. Where it looks at publicIp field in the return code to determine whether the allocation is for vpc or standard. This does not seem correct based on the documentation. It seems you should look at the domain argument instead. I fixed the issue for myself, but I am not sure this fix is correct.

Also while debugging the code I was not able to allocate an IP for standard domain at all. Is it possible that my AWS account has some sort of restriction where I can only allocate EIPs for VPC domain but not for standard that makes the API behave this way? Here is the debug log:

debug(aws.ec2::allocate_ip)

> ip.1 = aws.ec2::allocate_ip("standard")
debugging in: aws.ec2::allocate_ip("standard")

Browse[2]> n
debug: query <- list(Action = "AllocateAddress")
Browse[2]>
debug: if (!missing(domain)) {
    domain <- match.arg(domain)
    query$Domain <- domain
}
Browse[2]>
debug: domain <- match.arg(domain)
Browse[2]>
debug: query$Domain <- domain
Browse[2]>
debug: r <- ec2HTTP(query = query, ...)
Browse[2]> n
Browse[2]> print(r)
$requestId
$requestId[[1]]
[1] "aaaaaa-xxxx-xxxx-xxxx-ccccccccccc"


$publicIp
$publicIp[[1]]
[1] "xx.xxx.xx.xxx"


$domain
$domain[[1]]
[1] "vpc"     # >>>>>>>>> STILL VPC EVEN THOUGH I REQUESTED STANDARD


$allocationId
$allocationId[[1]]
[1] "eipalloc-xxxxxx"


attr(,"xmlns")
[1] "http://ec2.amazonaws.com/doc/2015-10-01/"

I'm not able to look at this at the moment but if you send a PR for the first issue, that would be great. Then I can look into the VPC vs. Standard aspect a bit later on. Sorry for not having time to figure it out right now.

@leeper See if this seems ok for you #27
Ty

Finally had a chance to look into this and I also cannot figure out how to generate an IP for EC2-Classic.

Help wanted!