-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
@aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudRelated to Amazon Elastic Compute CloudbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
Describe the bug
Provided user data by NatInstanceProviderV2 uses incorrect primary network interface eth0 instead of ens5 (or similar).
userData.addCommands(
'yum install iptables-services -y',
'systemctl enable iptables',
'systemctl start iptables',
'echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/custom-ip-forwarding.conf',
'sudo sysctl -p /etc/sysctl.d/custom-ip-forwarding.conf',
'sudo /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE',
'sudo /sbin/iptables -F FORWARD',
'sudo service iptables save',
);
Expected Behavior
Nat instance forwards traffic
Current Behavior
Traffic not forwarded
Reproduction Steps
Simply use the example snippet from cdk docs:
const provider = ec2.NatProvider.instanceV2({
instanceType,
defaultAllowedTraffic: ec2.NatTrafficDirection.OUTBOUND_ONLY,
});
new ec2.Vpc(this, 'TheVPC', {
natGatewayProvider: provider,
});
Possible Solution
Instead of hardcoding the network interface, use the actual from the os.
Additional Information/Context
No response
CDK CLI Version
2.133.0
Framework Version
No response
Node.js Version
OS
Language
TypeScript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudRelated to Amazon Elastic Compute CloudbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2