{"id":15061133,"url":"https://github.com/andreypopp/ocaml-tf","last_synced_at":"2025-07-23T00:05:04.361Z","repository":{"id":228213586,"uuid":"773407758","full_name":"andreypopp/ocaml-tf","owner":"andreypopp","description":"OCaml bindings to terraform/opentofu","archived":false,"fork":false,"pushed_at":"2025-04-02T14:38:48.000Z","size":52432,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T07:50:07.821Z","etag":null,"topics":["ocaml","terraform"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreypopp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-17T15:28:08.000Z","updated_at":"2025-04-02T14:38:54.000Z","dependencies_parsed_at":"2024-05-08T16:26:29.998Z","dependency_job_id":"8c8d7f29-10fd-4b92-ae3f-24b66bc030cf","html_url":"https://github.com/andreypopp/ocaml-tf","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"a009c88eab077a66ce232c1790e4a608f4dbeeb5"},"previous_names":["andreypopp/ocaml-tf"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/andreypopp/ocaml-tf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypopp%2Focaml-tf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypopp%2Focaml-tf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypopp%2Focaml-tf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypopp%2Focaml-tf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreypopp","download_url":"https://codeload.github.com/andreypopp/ocaml-tf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypopp%2Focaml-tf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266592195,"owners_count":23953109,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ocaml","terraform"],"created_at":"2024-09-24T23:09:44.603Z","updated_at":"2025-07-23T00:04:59.526Z","avatar_url":"https://github.com/andreypopp.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ocaml-tf\n\n**WARNING: EXPERIMENTAL, DO NOT USE**\n\n## how it works\n\nThe output of `terraform providers schema -json` is parsed and then used to\ngenerate OCaml code that provides a type-safe interface to define tf resources\nand datasources programmatically.\n\nEach provider is represented by a library, each resource or datasource is\nrepresented by a module.\n\nFor example for a resource named `digitalocean_droplet` there's a module\ngenerated with the following signature.\n\nFirst there are constructors for the resource block and for nested blocks:\n\n```ocaml\ntype timeouts\n\nval timeouts : ... -\u003e unit -\u003e timeouts\n\ntype digitalocean_droplet\n\nval digitalocean_droplet : image:string prop -\u003e ... -\u003e unit -\u003e digitalocean_droplet\n```\n\nFollowed by the function to serialize the resource to JSON:\n\n```ocaml\nval yojson_of_digitalocean_droplet : digitalocean_droplet -\u003e json\n```\n\nThen a type `t` is defined which represents the resource's exported attributes.\n\nOne can use values of such types to construct further resources which reference\nthe current resource:\n\n```ocaml\ntype t = private {\n  id : string prop;\n  ...\n}\n```\n\nTo obtain a value of `t` one can use the `register` function.\n\nThe function automatically registers the resource with the global registry\nwhich is then used to generate `.tf.json` file:\n\n```ocaml\nval register : ... string -\u003e t\n```\n\nIn case one wants to handle the registration manually, and have full control\nover `.tf.json` generation, there's a more low level api:\n\n```ocaml\nval make : string -\u003e t Tf_core.resource\n```\n\nThe `'attrs Tf_core.resource` type is a type contains attributes of the\nresource and the JSON payload to be written to the `.tf.json` file.\n\n## example\n\ndune:\n```\n(executable\n (name main)\n (modules main)\n (libraries tf tf_digitalocean))\n```\n\nmain.ml\n```ocaml\nopen Tf_core.Prop\nopen Tf_digitalocean\n\nlet public_key =\n  In_channel.(\n    with_open_bin \"/Users/andreypopp/.ssh/id_rsa.pub\" input_all)\n\nlet region = string \"fra1\"\n\nlet () =\n  let ssh_key =\n    Digitalocean_ssh_key.register \"id_rsa\" ~name:(string \"id_rsa\")\n      ~public_key:(string public_key)\n  in\n  let wg0_ip = Digitalocean_reserved_ip.register \"wg0_ip\" ~region in\n  let wg0 =\n    Digitalocean_droplet.register \"wg0\" ~name:(string \"wg0\") ~region\n      ~image:(string \"debian-12-x64\")\n      ~size:(string \"s-1vcpu-1gb\") ~ssh_keys:[ ssh_key.id ]\n  in\n  let _ =\n    Digitalocean_reserved_ip_assignment.register \"wg0_ip_assignment\"\n      ~droplet_id:(magic wg0.id) ~ip_address:wg0_ip.id\n  in\n  ()\n\nlet () = Tf_run.run ()\n```\n\nthen:\n```\ndune exec ./main.exe apply\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreypopp%2Focaml-tf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreypopp%2Focaml-tf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreypopp%2Focaml-tf/lists"}