# How to deploy lambda created with CDKTF using terraform?

**URL:** <https://discuss.hashicorp.com/t/how-to-deploy-lambda-created-with-cdktf-using-terraform/47817>\
**Category:** CDK for Terraform\
**Created:** [December 9, 2022, 10:01am UTC](https://discuss.hashicorp.com/t/how-to-deploy-lambda-created-with-cdktf-using-terraform/47817 "2022-12-09T10:01:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jatinmehrotra](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jatinmehrotra/32/32506_2.png) [@jatinmehrotra](https://discuss.hashicorp.com/u/jatinmehrotra)\
**Post date:** [December 9, 2022, 10:01am UTC](https://discuss.hashicorp.com/t/how-to-deploy-lambda-created-with-cdktf-using-terraform/47817/1 "2022-12-09T10:01:05Z")

</div>

I am trying to import/use CDKTF code into my existing Terraform project.

I am trying to implement Lambda with API gateway using typescript, and I figured out that working with typescript lambda + terraform is difficult.

So I am thinking to use CDKTF to generate zip, compiled TS code into JSON format and use that cdktf.json into may existing terraform code.

For simple CDKTF code like creating s3 bucket cdktf.json works with terraform deploy.

But when I am trying to deploy cdktf.json generate form this [tutorial](https://developer.hashicorp.com/terraform/tutorials/cdktf/cdktf-assets-stacks-lambda) it fails

It is failing at this `source` → ` unable to load "assets/lambda-asset/XXXXXXX8908/archive.zip": open assets/lambda-asset/XXXXXXXX12344XXX/archive.zip: no such file or directory`. Is it possible to extract zip file created from TerraformAsset or is there a solution to use plain HCL without any CDKTF?

```auto
"aws_s3_object": {
      "lambda-archive": {
        "//": {
          "metadata": {
            "path": "lambda-hello-world/lambda-archive",
            "uniqueId": "lambda-archive"
          }
        },
        "bucket": "${aws_s3_bucket.bucket.bucket}",
        "key": "v0.0.2/archive.zip",
        "source": "assets/lambda-asset/ABCDEDGHIJKLAMN000006786986/archive.zip"
      }
    },

```

---

<div class="post-metadata">

**Author:** ![jsteinich](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jsteinich/32/9502_2.png) [@jsteinich](https://discuss.hashicorp.com/u/jsteinich)\
**Post date:** [December 20, 2022, 3:47pm UTC](https://discuss.hashicorp.com/t/how-to-deploy-lambda-created-with-cdktf-using-terraform/47817/2 "2022-12-20T15:47:24Z")

</div>

If I’m understanding correctly you are running `cdktf synth`, but then deploying directly with the terraform cli.  
That’s definitely possible. One thing to watch out for is the path of execution. When you use `cdktf deploy`, the terraform cli is invoked from the the `cdktf.out/stacks/<stackname>` directory. This means that the assets are in a directory directly at the root of execution. If you invoke from somewhere else, then you’ll need to either alter the output or copy the `assets` directory. You could probably modify the `source` argument to be prefixed by [a path expansion](https://developer.hashicorp.com/terraform/language/expressions/references#filesystem-and-workspace-info) or the [abspath function](https://developer.hashicorp.com/terraform/language/functions/abspath) to make it work in other locations.
