Skip to content
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

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

aaronwalker
Copy link
Member

No description provided.

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}
Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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}"),
Copy link
Member Author

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]
    }

Copy link
Member Author

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

Copy link
Contributor

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

Copy link
Member Author

@aaronwalker aaronwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaronwalker aaronwalker changed the title DO NOT MERGE - Nat ENI via Launch Template Nat ENI via Launch Template and Amazon Linux 2023 support Jan 6, 2025
@aaronwalker aaronwalker merged commit 9209ffe into theonestack:master Jan 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants