mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-23 09:51:04 +01:00
Add destroy time flag (#580)
* Add destroy-time flag * Update changelog Fix cluster count * Fix cluster count * Fix docs * Fix outputs * Fix unsupported attribute on cluster_certificate_authority_data output Co-Authored-By: Daniel Piddock <33028589+dpiddockcmp@users.noreply.github.com> * Remove unnecessary flatten from cluster_endpoint output Co-Authored-By: Daniel Piddock <33028589+dpiddockcmp@users.noreply.github.com> * Improve description of var.enabled * Fix errors manifesting when used on an existing-cluster * Update README.md * Renamed destroy-time flag * Revert removal of changelog addition entry * Update flag name in readme * Update flag variable name * Update cluster referencing for consistency * Update flag name to `create_eks` * Fixed incorrect count-based reference to aws_eks_cluster.this (there's only one) * Replaced all incorrect aws_eks_cluster.this[count.index] references (there will be just one, so using '[0]'). * Changelog update, explicitly mentioning flag * Fixed interpolation deprecation warning * Fixed outputs to support conditional cluster * Applied create_eks to aws_auth.tf * Removed unused variable. Updated Changelog. Formatting. * Fixed references to aws_eks_cluster.this[0] that would raise errors when setting create_eks to false whilst having launch templates or launch configurations configured. * Readme and example updates. * Revert "Readme and example updates." This reverts commit 18a0746355e136010ad54858a1b518406f6a3638. * Updated readme section of conditionally creation with provider example. * Added conditions to node_groups. * Fixed reversed map_roles check * Update aws_auth.tf Revert this due to https://github.com/terraform-aws-modules/terraform-aws-eks/pull/611
This commit is contained in:
committed by
Max Williams
parent
7c2c4a6aa5
commit
124ea7c151
@@ -1,12 +1,12 @@
|
||||
# Worker Groups using Launch Templates
|
||||
|
||||
resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
count = local.worker_group_launch_template_count
|
||||
count = var.create_eks ? local.worker_group_launch_template_count : 0
|
||||
name_prefix = join(
|
||||
"-",
|
||||
compact(
|
||||
[
|
||||
aws_eks_cluster.this.name,
|
||||
aws_eks_cluster.this[0].name,
|
||||
lookup(var.worker_groups_launch_template[count.index], "name", count.index),
|
||||
lookup(var.worker_groups_launch_template[count.index], "asg_recreate_on_change", local.workers_group_defaults["asg_recreate_on_change"]) ? random_pet.workers_launch_template[count.index].id : ""
|
||||
]
|
||||
@@ -167,7 +167,7 @@ resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
[
|
||||
{
|
||||
"key" = "Name"
|
||||
"value" = "${aws_eks_cluster.this.name}-${lookup(
|
||||
"value" = "${aws_eks_cluster.this[0].name}-${lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"name",
|
||||
count.index,
|
||||
@@ -175,7 +175,7 @@ resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
"propagate_at_launch" = true
|
||||
},
|
||||
{
|
||||
"key" = "kubernetes.io/cluster/${aws_eks_cluster.this.name}"
|
||||
"key" = "kubernetes.io/cluster/${aws_eks_cluster.this[0].name}"
|
||||
"value" = "owned"
|
||||
"propagate_at_launch" = true
|
||||
},
|
||||
@@ -189,8 +189,8 @@ resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
"propagate_at_launch" = false
|
||||
},
|
||||
{
|
||||
"key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this.name}"
|
||||
"value" = aws_eks_cluster.this.name
|
||||
"key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this[0].name}"
|
||||
"value" = aws_eks_cluster.this[0].name
|
||||
"propagate_at_launch" = false
|
||||
},
|
||||
{
|
||||
@@ -218,8 +218,8 @@ resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
}
|
||||
|
||||
resource "aws_launch_template" "workers_launch_template" {
|
||||
count = local.worker_group_launch_template_count
|
||||
name_prefix = "${aws_eks_cluster.this.name}-${lookup(
|
||||
count = var.create_eks ? (local.worker_group_launch_template_count) : 0
|
||||
name_prefix = "${aws_eks_cluster.this[0].name}-${lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"name",
|
||||
count.index,
|
||||
@@ -364,7 +364,7 @@ resource "aws_launch_template" "workers_launch_template" {
|
||||
|
||||
tags = merge(
|
||||
{
|
||||
"Name" = "${aws_eks_cluster.this.name}-${lookup(
|
||||
"Name" = "${aws_eks_cluster.this[0].name}-${lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"name",
|
||||
count.index,
|
||||
@@ -382,7 +382,7 @@ resource "aws_launch_template" "workers_launch_template" {
|
||||
}
|
||||
|
||||
resource "random_pet" "workers_launch_template" {
|
||||
count = local.worker_group_launch_template_count
|
||||
count = var.create_eks ? local.worker_group_launch_template_count : 0
|
||||
|
||||
separator = "-"
|
||||
length = 2
|
||||
@@ -401,8 +401,8 @@ resource "random_pet" "workers_launch_template" {
|
||||
}
|
||||
|
||||
resource "aws_iam_instance_profile" "workers_launch_template" {
|
||||
count = var.manage_worker_iam_resources ? local.worker_group_launch_template_count : 0
|
||||
name_prefix = aws_eks_cluster.this.name
|
||||
count = var.manage_worker_iam_resources && var.create_eks ? local.worker_group_launch_template_count : 0
|
||||
name_prefix = aws_eks_cluster.this[0].name
|
||||
role = lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"iam_role_id",
|
||||
|
||||
Reference in New Issue
Block a user