Kubernetes provider for terraform: kubernetes_manifest

2 min read | by Jordi Prats

Since version 2.8.0 of the Kubernetes provider for terraform, the kubernetes_manifest resource is no longer considered experimental. With this resource we can push any kind of Kubernetes objects using terrraform that doesn't have a specific resource for it:

resource "kubernetes_manifest" "example_km" {
  manifest = yamldecode(<<-EOF
    apiVersion: v1
    kind: Namespace
      name: example-ns
        test: example

As shown, we can push the object using yamldecode() of writing the manifest using HCL as follows:

resource "kubernetes_manifest" "example_km_2" {
  manifest = {
    "apiVersion" = "v1"
    "kind"       = "Namespace"
    "metadata" = {
      "annotations" = {
        "test" = "example"
      "name" = "example-ns"

This resource is specially useful to be able to push CRDs using terraform. What we need to take into account is: Do we really want to mix the definition of Kubernetes objects into terraform? Maybe there are some use cases that make sense to use this resource, but we need to be careful with this resource.

If we try to use this resource using a Kubernetes provider prior to 2.8.0 (2.7.1, 2.7.0...) we will get the following error:

 Error: Experimental feature not enabled.
   with module.eks.kubernetes_manifest.example_km_2,
   on module/eks/sgs.tf line 1, in resource "kubernetes_manifest" "example_km_2":
    1: resource "kubernetes_manifest" "example_km_2" {
 The `kubernetes_manifest` resource is an experimental feature and must be explicitly enabled in the provider configuration block.

To enable the experimental feature we just need to add the following to the Kubernetes provider definition:

provider "kubernetes" {
  experiments { manifest_resource = true }

Posted on 11/02/2022