task:Day 30 in 100 days of AWS

I am not sure where it goes wrong , but the file still not getting uploaded to s3 bucket , all steps have been followed

1 . Create a Public subnet , auto-assign public ip
2 . Create a IGW and attach to priv-vpc
3. Add route in public subnet to IGW
4. Create NAT ec2 instance
5. Allow traffic from priv-subnet CIDR , disable source-dest check
6. Congifure IP tables in NAT instance
7. Add route in priv-subnet route to nat instance

This is the flow that is being followed . but the file is not getting uploaded in s3

Please refer to the solution shared here.

got it, just needed some changes in the steps to configuring the NAT instance.

#!/bin/bash
echo “net.ipv4.ip_forward = 1” >> /etc/sysctl.conf
sysctl -p
dnf install -y iptables-services
systemctl enable --now iptables
PUB_IFACE=$(ip -o route get 1.1.1.1 | awk ‘{for(i=1;i<=NF;i++) if ($i==“dev”) print $(i+1)}’)
PRIV_IFACE=eth1
iptables -F
iptables -t nat -F
iptables -t nat -A POSTROUTING -o “$PUB_IFACE” -j MASQUERADE
iptables -A FORWARD -i “$PRIV_IFACE” -o “$PUB_IFACE” -j ACCEPT
iptables -A FORWARD -i “$PUB_IFACE” -o “$PRIV_IFACE” -m state --state ESTABLISHED,RELATED -j ACCEPT
service iptables save

Try this script, it simplifies fetching the Interface:

USER_DATA='#!/bin/bash
# Enable IP forwarding
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p

# Install iptables
yum install -y iptables-services

# Discover interface used to talk to the outside world
IFACE=$(ip -o route get 1.1.1.1 | awk '/dev/ {print $5}')

# Configure iptables for NAT
iptables -t nat -A POSTROUTING -o "$IFACE" -j MASQUERADE
iptables -A FORWARD -i "$IFACE" -o "$IFACE" -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i "$IFACE" -o "$IFACE" -j ACCEPT

# Save iptables rules
iptables-save > /etc/sysconfig/iptables

Hi vijay hope your task is solved if you face any issue further regarding any task fell free to explore my solution where i explained every task in detail in a video lecture and also provided cli commands where needed , if you find my solution helpful make sure to give a star to my repo .

will do thanks reply

yeah, i had an issue with this one, but solved the problem, appreciate the assistance