T O P

How can I use Custom image id on Terraform while creating aws_eks_node_group?🙏🙏🙏

How can I use Custom image id on Terraform while creating aws_eks_node_group?🙏🙏🙏

Chokesi

You want to create a launch template using this I believe: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template then in your aws_eks_node_group, you would define the launch template w/ the parameter ``` launch_template - (Optional) Configuration block with Launch Template settings. Detailed below. launch_template Configuration Block NOTE: Either id or name must be specified. id - (Optional) Identifier of the EC2 Launch Template. Conflicts with name. name - (Optional) Name of the EC2 Launch Template. Conflicts with id. version - (Required) EC2 Launch Template version number. While the API accepts values like $Default and $Latest, the API will convert the value to the associated version number (e.g. 1) on read and Terraform will show a difference on next plan. Using the default_version or latest_version attribute of the aws_launch_template resource or data source is recommended for this argument. ``` Check the eks resource doc. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group. When I had setup ECS w/ terraform, I created a launch template, then an ASG group, then the cluster. That would define what image I wanted to use, cpus, mem and such. I no longer use the AWS provider, it's been a few years.


aayo-gorkhali

Thank you! after your recommendation I came across this article which seems very helpful. Thought I should share. Again thanks Much. https://wangpp.medium.com/terraform-eks-nodegroups-with-custom-launch-templates-5b6a199947f


Chokesi

Welcome happy terraforming!


backtickbot

[Fixed formatting.](https://np.reddit.com/r/backtickbot/comments/pldiad/httpsnpredditcomrterraformcommentsplbui3how_can_i/) Hello, Chokesi: code blocks using triple backticks (\`\`\`) don't work on all versions of Reddit! Some users see [this](https://stalas.alm.lt/backformat/hc9rz6w.png) / [this](https://stalas.alm.lt/backformat/hc9rz6w.html) instead. To fix this, **indent every line with 4 spaces** instead. [FAQ](https://www.reddit.com/r/backtickbot/wiki/index) ^(You can opt out by replying with backtickopt6 to this comment.)


aayo-gorkhali

In the above code, I have used: ami_type = "AL2_x86_64" which would automatically grab Amazon Linux 2 of the given architecture for my eks node group but I could not find how can I use Custom image id. If you guys have any idea please help?