Review container image references

Specify a verified image reference that can actually be pulled.

Description

An empty or incorrect image reference can prevent startup or select an unintended image. In image = "latest", latest is the repository name.

Potential impact

An image that cannot be found or pulled delays deployment and recovery. Even in the intended repository, a moved tag can make it hard to trace what ran.

Remediation

Specify the real registry and repository. Verify provenance, target platform and pull permissions. Use a reviewed tag or pin a verified digest when you need exact content. Test patches before updating.

Examples

nginx:1.7.9 is a historical example. Choose a maintained image for deployment.

Before

hcl
resource "kubernetes_pod" "example" {
  metadata {
    name = "terraform-example"
  }

  spec {
    container {
      image = "latest"
      name  = "example"
    }
  }
}

After

hcl
resource "kubernetes_pod" "example" {
  metadata {
    name = "terraform-example"
  }

  spec {
    container {
      image = "nginx:1.7.9"
      name  = "example"
    }
  }
}

The first configuration looks for the default latest tag in a repository named latest. The second looks for tag 1.7.9 in nginx. A version tag can also change its target.

References