{"id":13839192,"url":"https://github.com/skorfmann/cdktf-hybrid-module","last_synced_at":"2025-04-10T18:43:58.258Z","repository":{"id":42737972,"uuid":"282525572","full_name":"skorfmann/cdktf-hybrid-module","owner":"skorfmann","description":"A Terraform CDK Construct which is also usable as Terraform Module ","archived":false,"fork":false,"pushed_at":"2022-12-11T15:16:51.000Z","size":2677,"stargazers_count":7,"open_issues_count":13,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-16T10:58:13.959Z","etag":null,"topics":["cdk","cdktf","constructs","terraform","terraform-cdk","terraform-module"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skorfmann.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-25T21:11:25.000Z","updated_at":"2023-05-24T04:49:12.000Z","dependencies_parsed_at":"2023-01-27T01:46:27.468Z","dependency_job_id":null,"html_url":"https://github.com/skorfmann/cdktf-hybrid-module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorfmann%2Fcdktf-hybrid-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorfmann%2Fcdktf-hybrid-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorfmann%2Fcdktf-hybrid-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorfmann%2Fcdktf-hybrid-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skorfmann","download_url":"https://codeload.github.com/skorfmann/cdktf-hybrid-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271921,"owners_count":21075800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdk","cdktf","constructs","terraform","terraform-cdk","terraform-module"],"created_at":"2024-08-04T16:00:53.580Z","updated_at":"2025-04-10T18:43:58.237Z","avatar_url":"https://github.com/skorfmann.png","language":"TypeScript","funding_links":[],"categories":["Examples"],"sub_categories":[],"readme":"# A Terraform CDK Construct which is usable as Terraform Module as well\n\nThis repo demonstratest the usage of a [cdktf](https://cdk.tf) construct package as source for:\n\n- A native Terraform module\n- A construct consumable in `cdktf` distributed via NPM\n- A native Terraform module distributed via NPM ;)\n\nWhile this hybrid use-case isn't explictly supported in the Terraform CDK (`cdktf`) at the moment, it's totally possible do achieve this already.\n\n## Getting started\n\n```\ngit clone git@github.com:skorfmann/cdktf-hybrid-module.git\ncd cdktf-hybrid-module\nyarn\nyarn build\ncd examples/cdktf-example\n$(yarn bin)/cdktf diff\n```\n\nNB: The last step (`cdktf diff`) expects valid AWS credentials in ENV\n\n## The general idea\n\n- Synthesize a [stack without a provider](./packages/cdktf-hybrid-module/lib/module.ts) und use the synthesized folder as module.\n- Release the [construct](./packages/cdktf-hybrid-module/lib/construct.ts) as part of the npm package\n- As bonus, package the Terraform JSON as well, so you could use NPM as module manager\n\n![cdktf-and-terraform](./cdktf-and-terraform.png)\n\nSee also this [blog post](https://dev.to/skorfmann/a-terraform-cdk-construct-which-doubles-as-native-terraform-module-447k).\n\n## Examples\n\n- [cdktf construct](./examples/cdktf-example)\n- [Terraform module](./examples/terraform)\n- [Terraform module npm](./examples/terraform-npm)\n\n## Current Limitations\n\n- Outputs are already fully supported by `cdktf` but due to the random naming a bit hard to use. There' an [open issue](https://github.com/hashicorp/terraform-cdk/issues/247) to address this\n- Variables aren't directly supported in `cdktf`, but can still be done with [escape hatches](https://cdk.tf/escape-hatch). There's an [open issue](https://github.com/hashicorp/terraform-cdk/issues/249)\n- Since there aren't official prebuilt provider packages at the moment, this has to inline the generated constructs. That's the biggest drawback at the moment, but the work to improve this is underway - see this [open issue](https://github.com/hashicorp/terraform-cdk/issues/98).\n\n## Next Iteration\n\n- [ ] Add [jsii](https://cdk.tf/jsii) for polyglot package\n- [ ] Add unit tests\n- [ ] Come up with a more realistic example for the construct\n\n## Conclusion\n\nWhile it's not the best user experience at this point, I think this demonstrates that the [Terraform CDK](https://cdkt.tf) is capable of distributing hybrid modules. When the various issues around this topic are fixed, it'll be actually a pretty good user experience from my point of view.\n\n## Contributions\n\nContributions to this repository are more than welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorfmann%2Fcdktf-hybrid-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskorfmann%2Fcdktf-hybrid-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorfmann%2Fcdktf-hybrid-module/lists"}