Konubinix' opinionated web of thoughts

Terraform

Fleeting

terraform

Produit de Hashicorp.

terraform_data Managed Resource Type

useful […] for triggering provisioners when there is no other logical managed resource in which to place them.

https://developer.hashicorp.com/terraform/language/resources/terraform-data ([2025-04-07 Mon])

Example Usage (data for replace_triggered_by)

https://developer.hashicorp.com/terraform/language/resources/terraform-data ([2025-04-07 Mon])

variable “revision” { default = 1 }

resource “terraform_data” “replacement” { input = var.revision }

resource “example_database” “test” { lifecycle { replace_triggered_by = [terraform_data.replacement] } }

https://developer.hashicorp.com/terraform/language/resources/terraform-data ([2025-04-07 Mon])

lifecycle Meta-Argument

replace_triggered_by

replace_triggered_by (list of resource or attribute references) - Added in Terraform 1.2. Replaces the resource when any of the referenced items change. Supply a list of expressions referencing managed resources, instances, or instance attributes. When used in a resource that uses count or for_each, you can use count.index or each.key in the expression to reference specific instances of other resources that are configured with the same count or collection.

https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#replace_triggered_by ([2025-04-07 Mon])

eks nodegroup desired_size not updated

You can do it manually with awscli using

cluster_name="$(aws eks list-clusters | jq -r .clusters[0])"
nodegroup_name="$(aws eks list-nodegroups --cluster-name "${cluster_name}"|jq -r .nodegroups[0])"
aws eks update-nodegroup-config  --nodegroup-name "${nodegroup_name}" --cluster-name "${cluster_name}" --scaling-config 'maxSize=3'
aws eks update-nodegroup-config  --nodegroup-name "${nodegroup_name}" --cluster-name "${cluster_name}" --scaling-config 'desiredSize=3'
{
    "update": {
        "id": "8e6df717-99e3-310c-80ba-ce2747e474aa",
        "status": "InProgress",
        "type": "ConfigUpdate",
        "params": [
            {
                "type": "DesiredSize",
                "value": "3"
            }
        ],
        "createdAt": "2024-08-09T16:08:44.445000+02:00",
        "errors": []
    }
}

Autoscaling of nodes via cluster autoscaler or Karpenter is the preferred method by many

https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2030

Terraform does not allow for parameterizing ignore_changes at this time so this is the default effect

https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2030

It is assumed that most users will utilize a form of autoscaling that will manage the desired_size attribute of the node groups (i.e. - Cluster Autoscaler will manage this attribute for scaling), and therefore Terraform should not attempt to manage after it has been initially set during creation of the node group.

https://github.com/bryantbiggs/eks-desired-size-hack

Notes pointant ici