How User Data Works by Node Group Type
EKS Managed Node Groups
By default the EKS service appends its own bootstrap user data. Any user-supplied data is pre-pended before it. If a custom
ami_id is provided, the service no longer supplies bootstrap data — you must enable enable_bootstrap_user_data = true or provide your own template.Self Managed Node Groups
You are responsible for all bootstrapping. The module provides templates per AMI type that you opt into with
enable_bootstrap_user_data = true, or you can supply your own template via user_data_template_path.AL2023 (nodeadm / NodeConfig Format)
AL2023 uses thenodeadm bootstrapper with a MIME multipart cloud-init format. The key hook variables are cloudinit_pre_nodeadm and cloudinit_post_nodeadm.
Pre-nodeadm Cloud-Init Parts
Usecloudinit_pre_nodeadm to inject additional MIME parts before the nodeadm configuration part runs. Each entry becomes a separate part in the multipart document.
Post-nodeadm Cloud-Init Parts
Usecloudinit_post_nodeadm to inject MIME parts after the nodeadm configuration, for example to run a shell script after the node has joined the cluster.
NodeConfig Object Reference
Theapplication/node.eks.aws content type accepts a NodeConfig manifest. This is the canonical format for configuring nodeadm on AL2023:
AL2 (Legacy Bash Bootstrap)
ForAL2_* AMI types, user data is a bash script. Use pre_bootstrap_user_data, bootstrap_extra_args, and post_bootstrap_user_data to hook into the bootstrap process.
bootstrap_extra_args for AL2 AMIs are arguments passed directly to the AWS EKS Optimized AMI bootstrap script. Common uses include --kubelet-extra-args, --b64-cluster-ca, and --apiserver-endpoint.Custom AMI with Bootstrap User Data
When you specify a customami_id for an EKS managed node group, the EKS service no longer injects bootstrap data. You have two options:
Option 1: Use the Module-Provided Template
Opt in to the module’s built-in bootstrap template for EKS-optimized AMI derivatives:Option 2: Bring Your Own Template
For non-EKS-optimized AMIs or when you need full control over user data:Only the variables that the module passes to
templatefile() for the respective AMI type are available in your custom template. If you need additional values, pre-render the template before passing it to the module.Bottlerocket (TOML Format)
ForBOTTLEROCKET_* AMI types, user data must be in TOML format. When used with EKS managed node groups, the supplied TOML is merged with the configuration provided by the EKS service — there is no concept of pre/post bootstrap. Use bootstrap_extra_args to supply additional Bottlerocket settings.
Windows (PowerShell Format)
ForWINDOWS_* AMI types, user data is a PowerShell script.
Variable Reference
| Variable | AMI Types | Description |
|---|---|---|
cloudinit_pre_nodeadm | AL2023 | MIME parts injected before the nodeadm configuration part |
cloudinit_post_nodeadm | AL2023 | MIME parts injected after the nodeadm configuration part |
pre_bootstrap_user_data | AL2, Windows, Bottlerocket (not valid) | Script/data prepended before the bootstrap script |
post_bootstrap_user_data | AL2, Windows | Script/data appended after the bootstrap script |
bootstrap_extra_args | AL2 (bootstrap.sh args), Bottlerocket (TOML) | Additional arguments or settings for the bootstrap process |
enable_bootstrap_user_data | All (custom AMI) | Opt in to the module-provided bootstrap template when using a custom AMI |
user_data_template_path | All | Path to a custom template file rendered by the module in place of the default |
