awslabs/amazon-eks-ami

Execute custom command during bootstrapping process in AL2023

brizaldi opened this issue · 1 comments

When using Amazon Linux 2, we can insert custom commands to be executed during the bootstrapping process. Is there a way to achieve this in AL2023?

Example user data from Amazon Linux 2:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MY-BOUNDARY=="

--==MY-BOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
set -ex

# Custom commands
iptables -I INPUT -p tcp -m tcp --dport 10250 -j ACCEPT
#

/etc/eks/bootstrap.sh demo

--==MY-BOUNDARY==--

You can continue using this for AL2023 👍 (omitting the call to bootstrap.sh). It should already achieve what you're looking for since the nodeadm systemd services are strategically setup with the lifecycle of cloud-init.service in mind. Your code will run after generating configs but before components/service are started.