From af0c2168a96fc4cdb87a30f5a457b6d9999adbdb Mon Sep 17 00:00:00 2001 From: Pascal Bourdier Date: Thu, 23 Sep 2021 10:21:51 +0200 Subject: [PATCH] fix: launch_templates_with_managed_node_group example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove `instance_type` in `aws_launch_template.default` to avoid this error: ``` │ Error: error creating EKS Node Group (test-eks-lt-URZJOIL1:test-eks-lt-URZJOIL1-example2021092307395969650000000f): InvalidRequestException: Cannot specify instance types in launch template and API request │ { │ RespMetadata: { │ StatusCode: 400, │ RequestID: "bece44af-e7e0-4931-9725-4fb57a7de031" │ }, │ ClusterName: "test-eks-lt-URZJOIL1", │ Message_: "Cannot specify instance types in launch template and API request", │ NodegroupName: "test-eks-lt-URZJOIL1-example2021092307395969650000000f" │ } │ │ with module.eks.module.node_groups.aws_eks_node_group.workers["example"], │ on ../../modules/node_groups/main.tf line 1, in resource "aws_eks_node_group" "workers": │ 1: resource "aws_eks_node_group" "workers" { ``` replace it by `instance_types` in `node_groups` block of `module.eks` add a `custom_suffix` in `aws_iam_service_linked_role.autoscaling` to avoid conflict like: ``` │ Error: Error creating service-linked role with name autoscaling.amazonaws.com: InvalidInput: Service role name AWSServiceRoleForAutoScaling has been taken in this account, please try a different suffix. │ status code: 400, request id: e4ad4c1e-ad6e-4544-bed5-f3beeb148d29 │ │ with aws_iam_service_linked_role.autoscaling, │ on disk_encryption_policy.tf line 2, in resource "aws_iam_service_linked_role" "autoscaling": │ 2: resource "aws_iam_service_linked_role" "autoscaling" { ``` --- .../disk_encryption_policy.tf | 1 + .../launchtemplate.tf | 2 -- .../launch_templates_with_managed_node_groups/main.tf | 2 ++ .../variables.tf | 8 ++++---- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/launch_templates_with_managed_node_groups/disk_encryption_policy.tf b/examples/launch_templates_with_managed_node_groups/disk_encryption_policy.tf index 0362193505..3f834ad100 100644 --- a/examples/launch_templates_with_managed_node_groups/disk_encryption_policy.tf +++ b/examples/launch_templates_with_managed_node_groups/disk_encryption_policy.tf @@ -2,6 +2,7 @@ resource "aws_iam_service_linked_role" "autoscaling" { aws_service_name = "autoscaling.amazonaws.com" description = "Default Service-Linked Role enables access to AWS Services and Resources used or managed by Auto Scaling" + custom_suffix = "lt_with_managed_node_groups" # the full name is "AWSServiceRoleForAutoScaling_lt_with_managed_node_groups" < 64 characters } #data "aws_caller_identity" "current" {} diff --git a/examples/launch_templates_with_managed_node_groups/launchtemplate.tf b/examples/launch_templates_with_managed_node_groups/launchtemplate.tf index a393770f76..a2840ebc77 100644 --- a/examples/launch_templates_with_managed_node_groups/launchtemplate.tf +++ b/examples/launch_templates_with_managed_node_groups/launchtemplate.tf @@ -37,8 +37,6 @@ resource "aws_launch_template" "default" { } } - instance_type = var.instance_type - monitoring { enabled = true } diff --git a/examples/launch_templates_with_managed_node_groups/main.tf b/examples/launch_templates_with_managed_node_groups/main.tf index 78c2b31217..833b4b9f29 100644 --- a/examples/launch_templates_with_managed_node_groups/main.tf +++ b/examples/launch_templates_with_managed_node_groups/main.tf @@ -62,6 +62,8 @@ module "eks" { launch_template_id = aws_launch_template.default.id launch_template_version = aws_launch_template.default.default_version + instance_types = var.instance_types + additional_tags = { CustomTag = "EKS example" } diff --git a/examples/launch_templates_with_managed_node_groups/variables.tf b/examples/launch_templates_with_managed_node_groups/variables.tf index 351ffdb9cf..9bd936c6f8 100644 --- a/examples/launch_templates_with_managed_node_groups/variables.tf +++ b/examples/launch_templates_with_managed_node_groups/variables.tf @@ -1,6 +1,6 @@ -variable "instance_type" { - description = "Instance type" +variable "instance_types" { + description = "Instance types" # Smallest recommended, where ~1.1Gb of 2Gb memory is available for the Kubernetes pods after ‘warming up’ Docker, Kubelet, and OS - type = string - default = "t3.small" + type = list(string) + default = ["t3.small"] }