AndrewGuenther / fck-nat

Feasible cost konfigurable NAT: An AWS NAT Instance AMI
https://fck-nat.dev
MIT License
1.27k stars 50 forks source link

Support for Free Tier t2.micro? #94

Closed derrickgw closed 1 month ago

derrickgw commented 1 month ago

This project looks awesome.

I tried to deploy it using the only free-tier option, the t2.micro. Unfortunately: "The t2.micro instance type does not support an AMI with a boot mode of UEFI. Only instance types built on the Nitro System support UEFI."

How hard would it be to support the t2 instance? Is that something I can already do by using the machine image parameter?

AndrewGuenther commented 1 month ago

t3.micro is supported in free tier as well and is much more likely to be supported (though I haven't tested myself). Give that a try?

The docs say t3 instances are nitro, so that should work.

derrickgw commented 1 month ago

I am sure t3 would be supported, but alas, t3 is only free in regions where t2 is unavailable. :(

AndrewGuenther commented 1 month ago

Although this is very much in the spirit of fck-nat, I won't be able to support it at this time.

This would be a third dedicated AMI (on top of the x86 and ARM ones currently available) which would effectively increase hosting costs by 50%. The current AMIs cost ~$60 to host and that increases with each version released as well as additional testing burden for each release. That's just not something I can take on at the moment.

derrickgw commented 1 month ago

FortuNATly, I was able to get a NAT instance working with the following CDK code: The commands required to setup the NAT were pretty straight forward. With this I don't even have to worry about creating/maintaining a custom AMI image. It probably takes longer to launch the first time, but I don't think it will be an issue for me.

prefix = "https://raw.githubusercontent.com/AndrewGuenther/fck-nat/main/service"
nat_setup_cmds = [
    "sudo yum install iptables-services -y",
    "sudo mkdir /opt/fck-nat",
    f"sudo curl -o /opt/fck-nat/fck-nat.sh {prefix}/fck-nat.sh",
    f"sudo curl -o /etc/systemd/system/fck-nat.service {prefix}/fck-nat.service",
    "sudo chmod +x /opt/fck-nat/fck-nat.sh",
    "sudo systemctl enable fck-nat",
    "sudo systemctl start fck-nat",
]
setup = ec2.UserData.for_linux()
setup.add_commands(*nat_setup_cmds)

self.nat = ec2.NatProvider.instance_v2(
    instance_type=ec2.InstanceType.of(
        ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO
    ),
    machine_image=ec2.MachineImage.latest_amazon_linux2023(),
    default_allowed_traffic=ec2.NatTrafficDirection.OUTBOUND_ONLY,
    user_data=setup,
)

Thanks for all your work!

AndrewGuenther commented 1 month ago

Oh! This could actually be even easier! We distribute an RPM for each release. You can just rpm install that.