Created
January 5, 2022 00:20
-
-
Save joebernard/100ba280fdeba61d4a06990ab860ea78 to your computer and use it in GitHub Desktop.
Cheap and easy NAT instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired from here: https://www.kabisa.nl/tech/cost-saving-with-nat-instances/ | |
NatInstance: | |
Type: AWS::EC2::Instance | |
Properties: | |
InstanceType: t4g.micro | |
ImageId: ami-0a1eddae0b7f0a79f # Amazon Linux 2 AMI (HVM), SSD Volume Type, 64-bit ARM | |
SourceDestCheck: false | |
NetworkInterfaces: | |
- AssociatePublicIpAddress: true | |
DeviceIndex: "0" | |
GroupSet: | |
- { Fn::GetAtt: [vpc, DefaultSecurityGroup] } | |
SubnetId: | |
Ref: "subnetPublic1" | |
UserData: | |
Fn::Base64: !Sub | | |
#!/bin/bash -xe | |
sudo sysctl -w net.ipv4.ip_forward=1 | |
sudo /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment