Is there a way to run kubectl patch a deployment when relying on kubectl_manifest resource

Hi y’all,

I am currently deploying my Infrastructure via Terraform and on top of it I need to deploy some k8s manifest files (using kubectl_manifest resource) to deploy some additional services on top of my k8s cluster.

In this case, I need to run or patch one of the deployment with additional plugins (as a side car containers which are in yaml files).

How can I run a kubectl patch command while relying on kubectl_manifest resource?

Any takes on this one?

I found a way of setting it up via null_resource. This solves my prupose.

Unless if there is a way around kubectl_manifest, I am all ears :slight_smile:

[K8 RAG Assist]

To patch a deployment while using the kubectl_manifest resource in Terraform, you can either manually update the deployment YAML to include the sidecar containers before applying it with Terraform, or use Terraform’s templating to dynamically insert the containers into the YAML. Alternatively, you can use an external script with Terraform’s external data source to run kubectl patch outside of Terraform’s declarative approach. Directly running kubectl patch within the Terraform lifecycle requires external tools or custom solutions, as Terraform does not natively support imperative commands.