I'm trying update an existing kubectl_manifest
resource in my Terraform code but when I apply the changes, I get the following error:
Resource: "apiextensions.k8s.io/v1, Resource=customresourcedefinitions",
GroupVersionKind: "apiextensions.k8s.io/v1,
Kind=CustomResourceDefinition"
Name: "prometheuses.monitoring.coreos.com",
Namespace: "" for: "/var/folders/7y/_yfb9pcn01s56rx2tpwfnwk80000gp/T/598050506kubectl_manifest.yaml":
CustomResourceDefinition.apiextensions.k8s.io
"prometheuses.monitoring.coreos.com" is invalid:
metadata.annotations: Too long: must have at most 262144 bytes
on main.tf line 19, in resource "kubectl_manifest" "crd":
19: resource "kubectl_manifest" "crd" {
Here is my Terraform code snippet:
data "http" "yaml_file" {
url = var.crd_url
}
resource "kubectl_manifest" "crd" {
yaml_body = data.http.yaml_file.response_body
wait = true
wait_for_rollout = true
}
How to fix this?
Terraform Version: 0.14.2
AWS EKS Cluster Version: v1.23
I have added server_side_apply
with true
as its value in the kubectl_manifest
resource and it fixed the error.
Changed code is as follows:
resource "kubectl_manifest" "crd" {
yaml_body = data.http.yaml_file.response_body
server_side_apply = true
wait = true
wait_for_rollout = true
}
References: