Terraform
Fleetingterraform
Produit de Hashicorp.
terraform_data Managed Resource Type
- Référence externe : https://developer.hashicorp.com/terraform/language/resources/terraform-data
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 ( )
Example Usage (data for replace_triggered_by)
— https://developer.hashicorp.com/terraform/language/resources/terraform-data ( )
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 ( )
lifecycle Meta-Argument
- Référence externe : https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#replace_triggered_by
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 ( )
eks nodegroup desired_size not updated
- Référence externe : https://github.com/bryantbiggs/eks-desired-size-hack
- Référence externe : https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2030
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.
Notes pointant ici
- Allow `replace_triggered_by` to refer to module or module resource
- delete a Secrets Manager secret and create a new secret with the same name
- Force recreation of resource when other resource ist recreated/updated : r/Terraform
- infrastructure as code
- terraform aws ecs_service force_new_deployment how to make it work ?
- what is v1beta1.metrics.k8s.io and what does False (MissingEndpoints) means