{"id":19085137,"url":"https://github.com/riferrei/sample-terraform-provider","last_synced_at":"2026-05-06T15:40:01.591Z","repository":{"id":54864321,"uuid":"522718952","full_name":"riferrei/sample-terraform-provider","owner":"riferrei","description":"Sample code implementation for a Terraform provider","archived":false,"fork":false,"pushed_at":"2022-11-13T16:14:07.000Z","size":135,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-02T21:43:32.055Z","etag":null,"topics":["aws","devrel","hashicorp","terraform","terraform-provider"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riferrei.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":"2022-08-08T21:57:08.000Z","updated_at":"2023-12-17T01:07:56.000Z","dependencies_parsed_at":"2022-08-14T05:01:17.149Z","dependency_job_id":null,"html_url":"https://github.com/riferrei/sample-terraform-provider","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/riferrei%2Fsample-terraform-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riferrei%2Fsample-terraform-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riferrei%2Fsample-terraform-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riferrei%2Fsample-terraform-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riferrei","download_url":"https://codeload.github.com/riferrei/sample-terraform-provider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240136987,"owners_count":19753645,"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":["aws","devrel","hashicorp","terraform","terraform-provider"],"created_at":"2024-11-09T02:54:37.506Z","updated_at":"2026-05-06T15:39:56.548Z","avatar_url":"https://github.com/riferrei.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sample Terraform Provider\n=========================\n\nThis repository contains a sample code implementation for a Terraform provider. It is meant to be used as a way to teach, educate, and show the internals of a provider. Even if you are not looking to learn how to build custom providers, you may benefit from learning how one works behind the scenes. For more information about how to build custom providers, please visit the [HashiCorp Learn platform section about this](https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers).\n\n**Important**: this provider uses [OpenSearch](https://opensearch.org) as the upstream backend service. Before playing with the provider, you first need to get OpenSearch up-and-running. For simplicity, you can use the [docker-compose.yml](./docker-compose.yml) available in this repository.\n\nRequirements\n------------\n\n- [Terraform](https://www.terraform.io/downloads.html) 0.12+\n- [Go](https://golang.org/doc/install) 1.19 (to build the provider plugin)\n- [Docker](https://www.docker.com/get-started) 4.11+ (to execute the backend)\n\nBuilding the Provider\n---------------------\n\nTo play with this provider, first you have to build it. Then you must install the native executable generated into your local plugins folder as explained [here](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin). The easiest way to do wall of this is running the following command:\n\n```bash\nmake install\n```\n\nOnce you have done this, you can start writing your `.tf` files and run the command `terraform init` to initialize the plugins of your project.\n\nUsing the Provider\n------------------\n\nThe provider allows you to create, read, update, and delete characters from [Marvel](https://www.marvel.com). Here is an example that you can use to play with the provider:\n\n```tcl\nprovider \"sample\" {\n}\n\nresource \"sample_marvel_character\" \"deadpool\" {\n  fullname = \"Deadpool\"\n  identity = \"Wade Wilson\"\n  knownas = \"Merc with a Mouth\"\n  type = \"anti-hero\"\n}\n```\n\nDebugging the Provider\n----------------------\n\nThis provider was created using the [Terraform Plugin SDKv2](https://www.terraform.io/plugin/sdkv2), which allows developers to debug the code using tools like [delve](https://github.com/go-delve/delve). The code and build have been written to allow debugging, so all you have to do is starting a debugging session. You can do this using Visual Studio Code or via command-line.\n\n### Visual Studio Code\n\n1. Create a file named `launch.json` in the `.vscode` folder 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. Run the editor debugger. This will output the reattach configuration to the debug console.\n\n### Command-line\n\n1. Start a delve debugging session:\n\n```bash\ndlv exec --accept-multiclient --continue --headless ./terraform-provider-sample -- -debug\n```\n\nThis will output the reattach configuration to the output.\n\n### Debugging\n\nBefore issuing commands like `plan`, `apply`, and `destroy` to your Terraform code, you need to export the `TF_REATTACH_PROVIDERS` environment variable to reattach the CLI session to the started debugging server. After starting the debugging server session using one method above, the value to this variable will be provided. Here is an example of how to do this.\n\n```bash\nexport TF_REATTACH_PROVIDERS='{\"riferrei.com/terraform/sample\":{\"Protocol\":\"grpc\",\"Pid\":3382870,\"Test\":true,\"Addr\":{\"Network\":\"unix\",\"String\":\"/tmp/plugin713096927\"}}}'\n```\n\n# License\n\nThis project is licensed under the [Apache 2.0 License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friferrei%2Fsample-terraform-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friferrei%2Fsample-terraform-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friferrei%2Fsample-terraform-provider/lists"}