amazon-web-servicesterraformoutputtfstate

Share AWS resources between Terraform and CDK


My team has two completely different environments: a Terraform one (which allow us to create and manage some AWS resources as databases) and a CDK one, with contains API resources and its logics as well.

We would like to use databases resources created with Terraform in the CDK app.

I was looking for some simple way to import outputs or tfstate from Terraform into CDK app, but I've found nothing.

I'd like to know how'd you achieve something like that?


Solution

  • So, I finally solved this issue by using the tfstate file on CDK : our Remote Backend is AWS, so the tfstate is stored on S3. When we run the CDK app we fetch this file from S3 and we inject its outputs into an application service.

    It allows to always get the updated outputs from resources generated with Terraform.