-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nat ENI via Launch Template and Amazon Linux 2023 support #20
Conversation
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") | ||
INSTANCE_ID=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/2014-11-05/meta-data/instance-id -s) | ||
aws ec2 modify-network-interface-attribute --network-interface-id ${NetworkInterface#{az}} --no-source-dest-check --region ${AWS::Region} | ||
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchTemplate#{az} --region ${AWS::Region} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LewS This AMI doesn't have cfn-init installed the required package is aws-cfn-bootstrap
and it new path to cfn-init is /usr/bin/cfn-init
Gus had setup CloudInit metadata to create a systemd service to ensure nat at reboot not sure if want to do the same thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The userdata sets everything to survive a reboot, we don't need to create a system service, which would probably need rewriting. There's just source dest checking that is set on startup using Cron.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rspec tests are failing due to the change to the NetworkInterfaces changes. I think this needs to be made conditionally like the user data
vpc-v2.cfndsl.rb
Outdated
DeviceIndex: 0, | ||
AssociatePublicIpAddress: true, | ||
Groups: [ Ref(:NatInstanceSecurityGroup) ] | ||
NetworkInterfaceId: Ref("NetworkInterface#{az}"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LewS this needs to be made conditional to ensure backward compatibility probably something like
network_interfaces = {
DeviceIndex: 0,
AssociatePublicIpAddress: true,
Groups: [ Ref(:NatInstanceSecurityGroup) ]
}
if external_parameters[:nat_2023]
network_interfaces = {
NetworkInterfaceId: Ref("NetworkInterface#{az}"),
DeviceIndex: 0
}
end
template_data = {
TagSpecifications: [
{ ResourceType: 'instance', Tags: nat_tags },
{ ResourceType: 'volume', Tags: nat_tags }
],
ImageId: Ref(:NatAmi),
InstanceType: Ref(:NatInstanceType),
UserData: FnBase64(FnSub(nat_userdata)),
IamInstanceProfile: { Name: Ref(:NatInstanceProfile) },
NetworkInterfaces: [network_interfaces]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make this change the rspec tests should pass as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool, I'd forgotten that line had been changed. Will make the suggested changes @aaronwalker on monday morning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.