# Exec code without null resource?

**URL:** <https://discuss.hashicorp.com/t/exec-code-without-null-resource/48838>\
**Category:** CDK for Terraform\
**Created:** [January 11, 2023, 3:27pm UTC](https://discuss.hashicorp.com/t/exec-code-without-null-resource/48838 "2023-01-11T15:27:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrao](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/nrao/32/28628_2.png) [@nrao](https://discuss.hashicorp.com/u/nrao)\
**Post date:** [January 11, 2023, 3:27pm UTC](https://discuss.hashicorp.com/t/exec-code-without-null-resource/48838/1 "2023-01-11T15:27:03Z")

</div>

Is it possible to exec some code (in whatever language we’re coding in, e.g. C#) after a resource has been created? In HCL, we typically used a null resource and pointed it at a script, but how can we do it now without following the same pattern?

It would be awkward to have to create a null resource just to point it to itself to execute some code.

---

<div class="post-metadata">

**Author:** ![jbardin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbardin/32/3325_2.png) [@jbardin](https://discuss.hashicorp.com/u/jbardin)\
**Post date:** [January 11, 2023, 7:41pm UTC](https://discuss.hashicorp.com/t/exec-code-without-null-resource/48838/2 "2023-01-11T19:41:23Z")

</div>

A provisioner can be added to any managed resource, but if there is no single existing resource which makes sense to put the provisioner, a `null_resource` is just fine.

Using a `null_resource` isn’t creating anything externally, its only job is to manage the lifecycle of that bit if data in order to do things like trigger a provisioner. The only awkwardness is that Terraform itself isn’t necessarily well-suited for running external code, see [Provisioners are a Last Resort](https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#provisioners-are-a-last-resort)
