Description
A version tag can move to a different image, changing what the same Terraform configuration runs. Pin a verified digest when you need to reproduce the same content.
Potential impact
If the deployed image differs from the one you reviewed, it is harder to trace a deployment failure or investigate an incident.
Remediation
Check the image signature, provenance and vulnerabilities. Use the digest of an image for the target platform or an image index that includes it. Test patches before updating the pin.
Examples
Set image_repository to the real repository path. For verified_image_digest, supply the 64 hexadecimal digits of a maintained image’s SHA-256 digest. The expression already includes sha256:.
Before
resource "kubernetes_pod" "example" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
}
}
}
After
resource "kubernetes_pod" "example" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "${var.image_repository}@sha256:${var.verified_image_digest}"
name = "example"
}
}
}
nginx:1.7.9 is a mutable tag. The second configuration combines the repository and digest in the same Pod’s image field.