{"id":14957736,"url":"https://github.com/build-on-aws/custom-provider-with-terraform-plugin-framework","last_synced_at":"2025-08-12T21:05:54.287Z","repository":{"id":63649730,"uuid":"565953285","full_name":"build-on-aws/custom-provider-with-terraform-plugin-framework","owner":"build-on-aws","description":"This repository contains a complete implementation of a custom provider built using HashiCorp's latest SDK called Terraform plugin framework.","archived":false,"fork":false,"pushed_at":"2024-05-21T14:06:53.000Z","size":312,"stargazers_count":11,"open_issues_count":7,"forks_count":3,"subscribers_count":22,"default_branch":"main","last_synced_at":"2025-04-07T00:26:56.974Z","etag":null,"topics":["hashicorp","hashicorp-terraform","opensearch","opensearch-go","plugin-framework","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/build-on-aws.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-11-14T17:08:54.000Z","updated_at":"2025-03-28T10:45:45.000Z","dependencies_parsed_at":"2024-05-21T15:31:18.154Z","dependency_job_id":"8f1d677c-07b8-4b87-b3ad-70f22cf8ecae","html_url":"https://github.com/build-on-aws/custom-provider-with-terraform-plugin-framework","commit_stats":{"total_commits":46,"total_committers":3,"mean_commits":"15.333333333333334","dds":"0.13043478260869568","last_synced_commit":"2f5974b3e1482767e9557b2ac9015daafd4942f6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/build-on-aws/custom-provider-with-terraform-plugin-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/build-on-aws%2Fcustom-provider-with-terraform-plugin-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/build-on-aws%2Fcustom-provider-with-terraform-plugin-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/build-on-aws%2Fcustom-provider-with-terraform-plugin-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/build-on-aws%2Fcustom-provider-with-terraform-plugin-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/build-on-aws","download_url":"https://codeload.github.com/build-on-aws/custom-provider-with-terraform-plugin-framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/build-on-aws%2Fcustom-provider-with-terraform-plugin-framework/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270135057,"owners_count":24533196,"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-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["hashicorp","hashicorp-terraform","opensearch","opensearch-go","plugin-framework","terraform"],"created_at":"2024-09-24T13:15:30.050Z","updated_at":"2025-08-12T21:05:54.263Z","avatar_url":"https://github.com/build-on-aws.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Custom Provider with Terraform Plugin Framework\n\nThis repository contains a complete implementation of a custom provider built using the [Terraform plugin framework](https://developer.hashicorp.com/terraform/plugin/framework). It is used to teach, educate, and show the internals of a provider built with the latest SDK from [HashiCorp](https://www.hashicorp.com). Even if you are not looking to learn how to build custom providers, you may dial your troubleshooting skills to an expert level if you learn how one works behind the scenes. Plus, this provider is lots of fun to play with. The provider is called `buildonaws` and it allows you to maintain characters from comic books such as heros, super-heros, and villains.\n\n### Requirements\n\n* [Docker](https://www.docker.com/get-started)\n* [Golang 1.18+](https://go.dev/dl)\n* [Terraform 1.1.5+](https://www.terraform.io/downloads)\n\n## ⚙️ Building the provider\n\nThe first thing you need to do to use this connector is to build it.\n\n1. Install the following dependencies:\n\n- [Golang 1.18+](https://go.dev/dl)\n\n2. Execute the build file of the provider.\n\n```bash\nmake install\n```\n\n💡 A file named `~/.terraform.d/plugins/aws.amazon.com/terraform/buildonaws/1.0/${OS_ARCH}/terraform-provider-buildonaws` will be created. This is your custom provider.\n\n## ⬆️ Starting the provider backend\n\nThe provider uses [OpenSearch](https://opensearch.org) as the backend service to store and search for characters. Therefore, before playing with the provider, you first need to get OpenSearch up-and-running. For simplicity, this repository contains a [docker-compose.yml](./docker-compose.yml) file that you can use to execute OpenSearch as a container.\n\n1. Install the following dependencies:\n\n- [Docker](https://www.docker.com/get-started)\n\n2. Start the containers using Docker Compose.\n\n```bash\ndocker compose up -d\n```\n\nWait until the container `opensearch` is started and healthy.\n\n## ⏯ Playing with the provider\n\n1. Install the following dependencies:\n\n- [Terraform 1.1.5+](https://www.terraform.io/downloads)\n\n2. Enter the `examples` directory.\n\n```bash\ncd examples\n```\n\n3. Initialize the provider plugins.\n\n```bash\nterraform init\n```\n\n4. Check the execution plan.\n\n```bash\nterraform plan\n```\n\nOnce the command completes, you should see the following:\n\n```bash\nTerraform will perform the following actions:\n\n  buildonaws_character.daredevil will be created\n  + resource \"buildonaws_character\" \"daredevil\" {\n      + fullname     = \"Daredevil\"\n      + id           = (known after apply)\n      + identity     = \"Matt Murdock\"\n      + knownas      = \"The man without fear\"\n      + last_updated = (known after apply)\n      + type         = \"super-hero\"\n    }\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n\nChanges to Outputs:\n  + daredevil_secret_identity = \"The secret identity of Daredevil is 'Matt Murdock'\"\n  + deadpool_is_knownas       = \" is also known as ''\"\n╷\n│ Warning: Datasource was not loaded\n│ \n│   with data.buildonaws_character.deadpool,\n│   on example.tf line 13, in data \"buildonaws_character\" \"deadpool\":\n│   13: data \"buildonaws_character\" \"deadpool\" {\n│ \n│ Reason: no character with the identity 'Wade Wilson'.\n```\n\nNote the warning in the end. This means that the data-source from the provider was not able to find any characters stored in OpenSearch whose identity is `Wade Wilson`. To create this character in the backend, execute the following command:\n\n```bash\nsh deadpool.sh\n```\n\nCheck again:\n\n```bash\nterraform plan\n```\n\nOnce the command completes, you should have no more warnings.\n\n```bash\nTerraform will perform the following actions:\n\n  buildonaws_character.daredevil will be created\n  + resource \"buildonaws_character\" \"daredevil\" {\n      + fullname     = \"Daredevil\"\n      + id           = (known after apply)\n      + identity     = \"Matt Murdock\"\n      + knownas      = \"The man without fear\"\n      + last_updated = (known after apply)\n      + type         = \"super-hero\"\n    }\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n\nChanges to Outputs:\n  + daredevil_secret_identity = \"The secret identity of Daredevil is 'Matt Murdock'\"\n  + deadpool_is_knownas       = \"Deadpool is also known as 'Merch with a mouth'\"\n```\n\n5. Apply the configuration\n\n```bash\nterraform apply -auto-approve\n```\n\nOnce the command completes, you should see the outputs:\n\n```bash\nApply complete! Resources: 1 added, 0 changed, 0 destroyed.\n\nOutputs:\n\ndaredevil_secret_identity = \"The secret identity of Daredevil is 'Matt Murdock'\"\ndeadpool_is_knownas = \"Deadpool is also known as 'Merch with a mouth'\"\n```\n\nOnce you are done playing with the provider, you can destroy the resources created using:\n\n```bash\nterraform destroy -auto-approve\n```\n\n## 🪲 Debugging the provider\n\nThis is actually an optional step, but if you wish to debug the connector code to learn its behavior by watching the code executing line by line, you can do so by using [delve](https://github.com/go-delve/delve).\n\n1. Create a file named `.vscode/launch.json` with the following content:\n\n```json\n{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Debug Provider\",\n            \"type\": \"go\",\n            \"request\": \"launch\",\n            \"mode\": \"debug\",\n            \"program\": \"${workspaceFolder}\",\n            \"env\": {},\n            \"args\": [\n                \"-debug\",\n            ]\n        }\n    ]\n}\n```\n\n2. Set one or multiple breakpoints throughout the code.\n3. Launch a new debugging session in Visual Studio Code.\n4. In the debug console output you will see the following:\n\n```bash\nProvider started. To attach Terraform CLI, set the TF_REATTACH_PROVIDERS environment variable with the following:\n\n\tTF_REATTACH_PROVIDERS='{\"aws.amazon.com/terraform/buildonaws\":{\"Protocol\":\"grpc\",\"ProtocolVersion\":6,\"Pid\":00000,\"Test\":true,\"Addr\":{\"Network\":\"unix\",\"String\":\"/var/folders/jp/8jhflhbx6fj9_br8dwlfxn780000gr/T/plugin1062046873\"}}}'\n\n```\n\n💡 Please note that your `TF_REATTACH_PROVIDERS` environment variable will differ from what is shown here. Please don't copy the example above. You need to copy the one generated in your machine.\n\n5. Attach the Terraform CLI to the debugger\n\n```bash\nexport TF_REATTACH_PROVIDERS='{\"aws.amazon.com/terraform/buildonaws\":{\"Protocol\":\"grpc\",\"ProtocolVersion\":6,\"Pid\":00000,\"Test\":true,\"Addr\":{\"Network\":\"unix\",\"String\":\"/var/folders/jp/8jhflhbx6fj9_br8dwlfxn780000gr/T/plugin1062046873\"}}}'\n```\n\n6. Run any Terraform commands (plan, apply, destroy) that may trigger the breakpoints.\n\n## ⬇️ Stopping the provider backend\n\n1. Stop the containers using Docker Compose.\n\n```bash\ndocker compose down\n```\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n\n## License\n\nThis project is licensed under the MIT-0 License. See the [LICENSE](./LICENSE) file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuild-on-aws%2Fcustom-provider-with-terraform-plugin-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuild-on-aws%2Fcustom-provider-with-terraform-plugin-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuild-on-aws%2Fcustom-provider-with-terraform-plugin-framework/lists"}