aws.ec2 icon indicating copy to clipboard operation
aws.ec2 copied to clipboard

API not associating Elastic IPs with allocation ID for VPC

Open itissid opened this issue 7 years ago • 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/"

itissid avatar Oct 06 '17 15:10 itissid

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 avatar Oct 06 '17 15:10 leeper

@leeper See if this seems ok for you https://github.com/cloudyr/aws.ec2/pull/27 Ty

itissid avatar Oct 08 '17 16:10 itissid

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

Help wanted!

leeper avatar Jul 24 '18 14:07 leeper