Closed m-radzikowski closed 9 months ago
Just want to ack that this is on my radar and I'll get back to you when some other projects die down.
EIP configuration support has landed in fck-nat
as part of https://github.com/AndrewGuenther/fck-nat/pull/44
That change will get released as part of the 1.3 release at the end of the month.
You can pretty easily now add to the user data this value and it will work for both HA and non-HA. Leaving this open because in the next release I'd like to add more direct support in the construct to pass the EIP id.
@AndrewGuenther any idea when 1.3 might be released? EIP config would be great for our use case.
@nguyendon I've updated the release timeline for 1.3 to end of this month. Things got a bit crazy with the holiday and I'm also changing jobs so I haven't had much time to get 1.3 out the door. I've got the next two weeks off though and 1.3 is definitely one of my priorities during that time.
Thanks for the update and congrats on the new gig 🎉
Hey, multiple people recommended fck-nat on Twitter, and I must say - great job, and having CDK support is a cherry on top.
However, I need a static IP for my NAT Gateway (with Elastic IP). I saw the https://github.com/AndrewGuenther/fck-nat/issues/14 but HA with EIP was not resolved there.
I made it work, but the solution is quite ugly.
No-HA
With a no-HA setup you can easily attach EIP - working example:
We can test it with this small Lambda:
The instance has 1 Network Interface attached with EIP assigned. This interface is
eth0
and is set as the output in the iptables nat table:HA
Now, with HA things get complicated.
The
FckNatInstanceProvider
creates a "permanent" Network Interface that is set as a target for private subnet routing. It also creates an AutoScaling Group. Instance that starts in the ASG gets a "regular" Network Interface oneth0
and then runsaws ec2 attach-network-interface
to attach the other, "permanent" Network Interface, aseth1
.Then it sets the NAT routing to use
eth0
, just like in the no-HA setup.Now, the simplest solution would be to attach EIP to this "permanent" Network Interface and route the output traffic through it. The code changes slightly:
However, when I try to change NAT table to use
eth1
, traffic does not flow and requests time out:And I don't know why. I'm also not good enough with networks to figure it out.
The
eth1
interface connects to the internet from the instance -curl --interface eth1 https://api.my-ip.io/ip.json
works.The other solution would be to associate EIP with the
eth0
interface with AWS CLI from the instance, and I made it work.Instead of creating
CfnEIPAssociation
in the previous code, we do this:Ugly, but it works. We provide a list of EIPs and the script finds the first free one and associates it.
The script in more readable version:
So those are solutions to set up fck-nat with Elastic IP, with no-HA and HA version.
If you want, I can create a PR to add those examples to the docs. I think a few people would be interested.
The other thing - I would really want to make it work with EIP associated through the IaC, but the problem is with routing through
eth1
. Are you able to help with that?