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

Allow alternative user_data format in node_groups #1644

Closed
scalen opened this issue Oct 14, 2021 · 6 comments · Fixed by #1680
Closed

Allow alternative user_data format in node_groups #1644

scalen opened this issue Oct 14, 2021 · 6 comments · Fixed by #1680

Comments

@scalen
Copy link

scalen commented Oct 14, 2021

Is your request related to a new offering from AWS?

Yes (ish) - It relates to supporting the Bottlerocket AMI using node_groups.

Is your request related to a problem? Please describe.

The node_groups module is more opinionated about the user_data for a node group than the worker_groups configuration was, forcing either:

  • Use of sh-based cloud-init user data.
  • Specification of the complete Launch Template outside of the module

Bottlerocket (a hardened AMI designed for use as a worker node in EKS) uses raw TOML for its user data, not embedded in cloud-init or a shell.

As such, it is very easy to create an older worker_group based on Bottlerocket, but very labour intensive and brittle to create a newer node_group, even when wishing to reuse all of the other Launch Template features provided in this module.

Describe the solution you'd like.

I would like to see the userdata_template_file and userdata_template_extra_args (or similar) module variables replicated from the parent module to the node_groups module. This could easily be made to work with the cloudinit_config resource, which already does templating. To be completely accurate, it should also be possible to set the MIME type of the resulting config file with something along the lines of userdata_mime_type, or to leave it unset when needing raw user data.

I would probably modify the shape of the above recommended variables to be the following, but this is just because I like nested configuration:

variable "user_data" {
  type    = map
  default = {
    template_file       = "${path.module}/templates/userdata.sh.tpl"
    template_extra_args = {}
    mime_type           = "text/x-shellscript"
  }
}

Describe alternatives you've considered.

The only alternative to the above, whilst still using node_groups, appears to be to set create_launch_template to false, duplicate all of the behaviour outside of the module, then pass in the launch_template_id.

However, this is brittle (liable to falling behind the launch configuration in this module) and hard to achieve (as many of the variables set in this module's launch templates are derived from values derived from the inner workings of the module). As such, I do not see it as a truly viable alternative.

The other alternative is to use the older worker_groups variable. However, this suffers from other issues that are solved by node_groups, taking for example the issue of worker group identification in Terraform state as an item in a list: if removing a worker group from the middle of the list, Terraform will instead see the last group in the list removed, and every group from the logically removed group onward as, instead, modified, resulting in their tear down and recreation. node_groups solves this, but cannot currently be used due to the problem that is the subject of this Issue.

@scalen scalen changed the title Allow alternate user_data format in node_groups Allow alternative user_data format in node_groups Oct 15, 2021
@ismailbaskin
Copy link

AWS provider ( v3.64.0) supports BOTTLEROCKET_x86_64 but hardcoded userdata.sh.tpl does not allow to use it. hashicorp/terraform-provider-aws#21548

@scalen
Copy link
Author

scalen commented Nov 5, 2021

AWS provider ( v3.64.0) supports BOTTLEROCKET_x86_64 but hardcoded userdata.sh.tpl does not allow to use it. hashicorp/terraform-provider-aws#21548

Exactly. That is what the linked PR is designed to fix 🙂

@github-actions
Copy link

github-actions bot commented Dec 6, 2021

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Dec 6, 2021
@scalen
Copy link
Author

scalen commented Dec 6, 2021

/active

@antonbabenko
Copy link
Member

This issue has been resolved in version 18.0.0 🎉

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants