Hello,
i wonder if there is a clever way to ignore some of the changes in a referenced resource ?
For example, I do not want aws_instance resource to restart when there are changes int the instance_profile policies. At the same time i do want to have a default (restart) behavior for all other changes in the instance_profile…
e.g.
If i update the vm_profille name → i’l like the vm resource to be restarted.
if i update a list of policies in the vm_profile → i do not want a vm resource to be restarted.
By default, aws_instance is restarted when instance_profile changes.
A general code example:
resource "aws_iam_role" "VM_role" {
name = "DS_VM_role"
description = "Role for DS VMs"
...
}
resource "aws_iam_instance_profile" "VM_profile" {
...
role = aws_iam_role.VM_role.name
...
}
resource "aws_iam_role_policy_attachment" "this" {
for_each = tomap({
"1" = data.aws_iam_policy.iam_policy_s3.arn,
...
})
}
resource "aws_instance" "this" {
...
iam_instance_profile = aws_iam_instance_profile.VM_profile
...
}
REF: The lifecycle Meta-Argument - Configuration Language | Terraform | HashiCorp Developer