Is it possible to deploy resources directly using Python and Terraform CDK from code and not CLI?

446 Views Asked by At

I am looking for a App.deploy() function that can directly deploy/provision infra, just like we have App.synth(). Is it possible to directly deploy resources from code itself without having to deal with CLI for deployment?

1

There are 1 best solutions below

1
On

The short answer is: no. Even though, as @gshpychka mentioned, you can use code to execute shell commands, that still involves "dealing with the CLI".

The larger question is -- why do you want to avoid using the CLI? Generally speaking, deploying infra is either going to be a one-off task you perform locally, in which case it makes sense to use the CLI, or it is going to be a frequently repeated task performed by a pipeline...in which case it also makes sense for it to be triggered via CLI. What problem are you trying to solve by not interacting with shell commands?