{"id":24744355,"url":"https://github.com/stefaanc/terraform-provider-hyperv","last_synced_at":"2026-04-28T23:03:07.244Z","repository":{"id":77671093,"uuid":"211815606","full_name":"stefaanc/terraform-provider-hyperv","owner":"stefaanc","description":"a terraform provider to work with hyper-v","archived":false,"fork":false,"pushed_at":"2019-11-19T12:36:02.000Z","size":13137,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T02:17:56.701Z","etag":null,"topics":["hyper-v","terraform","terraform-plugins","terraform-provider","terraform-provider-hyperv"],"latest_commit_sha":null,"homepage":"","language":"Go","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/stefaanc.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":"2019-09-30T08:43:38.000Z","updated_at":"2019-10-25T11:41:16.000Z","dependencies_parsed_at":"2023-08-25T13:03:00.093Z","dependency_job_id":null,"html_url":"https://github.com/stefaanc/terraform-provider-hyperv","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/stefaanc%2Fterraform-provider-hyperv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fterraform-provider-hyperv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fterraform-provider-hyperv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fterraform-provider-hyperv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefaanc","download_url":"https://codeload.github.com/stefaanc/terraform-provider-hyperv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245028201,"owners_count":20549474,"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":["hyper-v","terraform","terraform-plugins","terraform-provider","terraform-provider-hyperv"],"created_at":"2025-01-28T02:18:03.202Z","updated_at":"2026-04-28T23:03:02.214Z","avatar_url":"https://github.com/stefaanc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform Provider Hyper-V\r\n\r\n**a terraform provider to work with hyper-V**\r\n\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n### !!! UNDER CONSTRUCTION !!!!!!!!\r\n\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n## Prerequisites\r\n\r\nTo build:\r\n- [GNU make](https://www.gnu.org/software/make/)\r\n- [Golang](https://golang.org/) \u003e= v1.13\r\n- [Terraform plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) ~= v1.0.0\r\n\r\nTo use:\r\n- [Terraform](https://terraform.io) \u003e= v0.12.9\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## Building The Provider\r\n\r\n1. Clone the git-repository on your machine\r\n\r\n   ```shell\r\n   mkdir -p $my_repositories\r\n   cd $my_repositories\r\n   git clone git@github.com:stefaanc/terraform-provider-hyperv\r\n   ```\r\n   \u003e `$my_repositories` must point to the directory where you want to clone the repository\r\n   \r\n2. Build the provider\r\n\r\n   ```shell\r\n   cd $my_repositories/terraform-provider-hosts\r\n   make release\r\n   ```\r\n\r\n   This will build the provider and put it in \r\n   - `%AppData%\\terraform.d\\plugins` on Windows\r\n   - `$HOME\\.terraform.d\\plugins` on Linux\r\n\u003cbr/\u003e\r\n\r\n \u003e :bulb:  \r\n \u003e The makefile provides more commands: `tidy`, `test`, `log`, `report`, `testacc`, `build`, ...\r\n    \r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## Installing The Provider\r\n\r\n1. Download the provider to your machine\r\n\r\n   - go to [the releases tab on github](https://github.com/stefaanc/terraform-provider-hyperv/releases)\r\n   - download the file that is appropriate for your machine\r\n\r\n2. Move the provider from your `Downloads` folder to\r\n\r\n   - `%AppData%\\terraform.d\\plugins` on Windows\r\n   - `$HOME\\.terraform.d\\plugins` on Linux\r\n\u003cbr/\u003e\r\n\r\n\u003e :bulb:  \r\n\u003e Alternatively, you can try our latest release-in-progress under the `releases` folder.  No guarantee though this will be a fully working provider.\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## Using The Provider\r\n\r\n\u003e :bulb:  \r\n\u003e You can find the some of following examples (and more) under the `examples` folder\r\n\r\n### provider \"hyperv\"\r\n\r\nConfigures a provider for a Hyper-V server.\r\n \r\n```terraform\r\nprovider \"hyperv\" {}\r\n```\r\n \r\n```terraform\r\nprovider \"hyperv\" {\r\n    type = \"local\"\r\n}\r\n```\r\n\r\n```terraform\r\nprovider \"hyperv\" {\r\n    type     = \"ssh\"\r\n    host     = \"localhost\"\r\n    port     = 22\r\n    user     = \"me\"\r\n    password = \"my-password\"\r\n    insecure = true\r\n}\r\n```\r\n\r\nArguments  | \u0026nbsp;   | Description\r\n:----------|:--------:|:-----------\r\n`type`     | Optional | The type of connection to the hyperv-server: `\"local\"` or `\"ssh\"`.  \u003cbr/\u003e- defaults to `\"local\"`\r\n---------- | \u0026nbsp;   | \u0026nbsp;\r\n`host`     | Optional | The hyperv-server. \u003cbr/\u003e- ignored when `type = \"local\"` \u003cbr/\u003e- defaults to `\"localhost\"`\r\n`port`     | Optional | The hyperv-server's port for ssh. \u003cbr/\u003e- ignored when `type = \"local\"` \u003cbr/\u003e- defaults to `22`\r\n`user`     | Optional | The user name for communication with the hyperv-server. \u003cbr/\u003e- ignored when `type = \"local\"` \u003cbr/\u003e- required when `type = \"ssh\"`\r\n`password` | Optional | The user password for communication with the hyperv-server. \u003cbr/\u003e- ignored when `type = \"local\"` \u003cbr/\u003e- required when `type = \"ssh\"`\r\n`insecure` | Optional | Allow insecure communication - disables checking of the server certificate. \u003cbr/\u003e- ignored when `type = \"local\"` \u003cbr/\u003e- defaults to `false` \u003cbr/\u003e\u003cbr/\u003e When `insecure = false`, the hyperv-server's certificate is checked against the user's known hosts, as specified by the file `~/.ssh/known_hosts`.  \r\n\r\n\u003e :bulb:  \r\n\u003e The Hyper-V API needs elevated credentials (\"Run as Administrator\") for all methods.\r\n\u003e When using `type = \"local\"`, you need to run terraform from an elevated shell.\r\n\u003e When using `type = \"ssh\"`, terraform will always use the most elevated credentials available to the configured user.\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## Data-sources\r\n\r\n### data \"hyperv_vswitch\"\r\n\r\nReads a Hyper-V virtual switch.\r\n\r\n```terraform\r\ndata \"hyperv_vswitch\" \"default\" {\r\n    name = \"Default Switch\"\r\n}\r\n```\r\n\r\nArguments     | \u0026nbsp;   | Description\r\n:-------------|:--------:|:-----------\r\n`name`        | Required | The name of the virtual switch.\r\n----------    | \u0026nbsp;   | \u0026nbsp;\r\n`x_lifecycle` | Optional | see [x_lifecycle for data-sources](#extended-lifecycle-customizations-for-data-sources)\r\n  \r\nExports                             | \u0026nbsp;   | Description\r\n:-----------------------------------|:--------:|:-----------\r\n`switch_type`                       | Computed | The type of virtual switch: `\"private\"`, `\"internal\"` or `\"external\"`.\r\n`notes`                             | Computed | Notes added to the virtual switch.\r\n`allow_management_os`               | Computed | The hyperv-server is allowed to participate into the communication on the virtual switch. \r\n`net_adapter_name`                  | Computed | The name of the network adapter used for an \"external\" virtual switch.\r\n`net_adapter_interface_description` | Computed | The description for the network adapter interface used for an \"external\" virtual switch.\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n### extended lifecycle customizations for data-sources\r\n\r\nThe `x_lifecycle` block defines extensions to the terraform lifecycle customizations meta-data for data-sources (although at moment of writing this text, there are no such lifecycle customizations defined for data-sources).  As opposed to the terraform meta-data, that can be added to all of the configured data-sources, the `x_lifecycle` block can only be added to the data-sources that implement this block.\r\n\r\n```terraform\r\ndata \"hyperv_vswitch\" \"default\" {\r\n    name = \"Default Switch\"\r\n\r\n    x_lifecycle {\r\n        ignore_error_if_not_exists = true\r\n    }\r\n}\r\n```\r\n\r\nArguments                                | \u0026nbsp;   | Description\r\n:----------------------------------------|:--------:|:-----------\r\n`x_lifecycle.ignore_error_if_not_exists` | Optional | Ignores the \"cannot find\" or \"doesn't exist\" errors from the API.  \u003cbr/\u003e\u003cbr/\u003eThis can be used to test if a data-source exists.  For example, the \"Default Switch\" doesn't exist in older versions of Hyper-V, and does exist by default in newer versions of Hyper-V.\r\n  \r\nExports              | \u0026nbsp;   | Description\r\n:--------------------|:--------:|:-----------\r\n`x_lifecycle.exists` | Computed | Set to `true` if the data-source exists.\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## Resources\r\n\r\n### resource \"hyperv_vswitch\"   \r\n\r\n```terraform\r\nresource \"hyperv_vswitch\" \"private\" {\r\n    provider = hyperv.local\r\n\r\n    name                = \"Private Switch\"\r\n    switch_type         = \"private\"\r\n    notes               = \"private notes\"\r\n}\r\n```\r\n\r\n```terraform\r\nresource \"hyperv_vswitch\" \"internal\" {\r\n    provider = hyperv.local\r\n\r\n    name                = \"Internal Switch\"\r\n    switch_type         = \"internal\"\r\n    notes               = \"internal notes\"\r\n}\r\n```\r\n\r\n```terraform\r\nresource \"hyperv_vswitch\" \"external\" {\r\n    provider = hyperv.local\r\n\r\n    name                = \"External Switch\"\r\n    switch_type         = \"external\"\r\n    notes               = \"external notes\"\r\n\r\n    allow_management_os = true\r\n    net_adapter_interface_description = \"Intel(R) 82579LM Gigabit Network Connection\"\r\n}\r\n```\r\n\r\nArguments                           | \u0026nbsp;   | Description\r\n:-----------------------------------|:--------:|:-----------\r\n`name`                              | Required | The name of the virtual switch.\r\n`switch_type`                       | Required | The type of virtual switch: `\"private\"`, `\"internal\"` or `\"external\"`.\r\n`notes`                             | Optional | Notes added to the virtual switch.\r\n----------                          | \u0026nbsp;   | \u0026nbsp;\r\n`allow_management_os`               | Optional | The hyperv-server is allowed to participate into the communication on the virtual switch.  \u003cbr/\u003e- must not be configured or set to `false` when `switch_type = \"private\"`.  \u003cbr/\u003e- must not be configured or set to `true` when `switch_type = \"internal\"`  \u003cbr/\u003e- defaults to `false` when `switch_type = \"external\"`\r\n`net_adapter_name`                  | Optional | Use the existing network adapter with this name.  \u003cbr/\u003e- must not be configured when `switch_type = \"private\"` or `switch_type = \"internal\"`  \u003cbr/\u003e- must not be configured  when `switch_type = \"external\"` and `net_adapter_interface_description` is configured  \u003cbr/\u003e- required when `switch_type = \"external\"` and `net_adapter_interface_description` is not configured \r\n`net_adapter_interface_description` | Optional | Disable existing network adapter and create new network adapter for this interface.  \u003cbr/\u003e- must not be configured when `switch_type = \"private\"` or `switch_type = \"internal\"`  \u003cbr/\u003e- must not be configured when `switch_type = \"external\"` and `net_adapter_name` is configured  \u003cbr/\u003e- required when `switch_type = \"external\"` and `net_adapter_name` is not configured\r\n----------                          | \u0026nbsp;   | \u0026nbsp;\r\n`x_lifecycle`                       | Optional | see [x_lifecycle for resources](#extended-lifecycle-customizations-for-resources)\r\n  \r\nExports                             | \u0026nbsp;   | Description\r\n:-----------------------------------|:--------:|:-----------\r\n`allow_management_os`               | Computed | The hyperv-server is allowed to participate into the communication on the virtual switch. \r\n`net_adapter_name`                  | Computed | The name of the network adapter used for an \"external\" virtual switch.\r\n`net_adapter_interface_description` | Computed | The description for the network adapter interface used for an \"external\" virtual switch.\r\n\r\n**_Importing a hyperv_vswitch using terraform import_**\r\n\r\nYou can import a virtual switch using the switch's name as an import ID.\r\n\r\n- Assuming a configuration\r\n\r\n  ```terraform\r\n  provider \"hyperv\" {}\r\n\r\n  resource \"hyperv_vswitch\" \"default\" {\r\n      name        = \"Default Switch\"\r\n      switch_type = \"internal\"\r\n      notes       = \"internal notes\"\r\n  }\r\n  ```\r\n\r\n  When terraform tries to create this then this will fail when the virtual switch already exists.  You can delete the switch from the infrastructure, and then re-create it using terraform.  However, this may be a bit more involved when you need to automate this.  Alternatively you can import it.\r\n\r\n- Run the terraform import command using the name of the switch as import ID.\r\n\r\n  ```shell\r\n  terraform import \"hyperv_vswitch.default\" \"Default Switch\"\r\n  ```\r\n\r\n  The resource will be imported into the terraform state, and the usual lifecycle will be applied next time `terraform apply` is run.\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n### extended lifecycle customizations for resources\r\n\r\nThe `x_lifecycle` block defines extensions to the terraform lifecycle customizations meta-data for resources.  As opposed to the terraform meta-data, that can be added to all of the configured resources, the `x_lifecycle` block can only be added to the resources that implement this block.\r\n\r\n```terraform\r\nresource \"hyperv_vswitch\" \"default\" {\r\n    name        = \"Default Switch\"\r\n    switch_type = \"internal\"\r\n\r\n    x_lifecycle {\r\n        import_if_exists = true\r\n    }\r\n}\r\n```\r\n\r\nArguments                         | \u0026nbsp;   | Description\r\n:---------------------------------|:--------:|:-----------\r\n`x_lifecycle.import_if_exists`    | Optional | Imports the resource when it does exist, avoiding the \"already exists\" errors from the API.  \u003cbr/\u003e\u003cbr/\u003eThis can be used in cases where existence of a resource is unknown and would require \"obscure\" configuration to test and decide if the resource needs creating.  For example, the \"Default Switch\" doesn't exist in older versions of Hyper-V, and does exist by default in newer versions of Hyper-V.\r\n`x_lifecycle.destroy_if_imported` | Optional | Destroys the imported resource when using `terraform destroy`.  \u003cbr/\u003e\u003cbr/\u003eBy default, a resource that is imported using `import_if_exists = \"true\"` is **not** destroyed when using `terraform destroy`.\r\n  \r\nExports                | \u0026nbsp;   | Description\r\n:----------------------|:--------:|:-----------\r\n`x_lifecycle.imported` | Computed | Set to `true` when the resource is imported using `import_if_exists = \"true\"`. \r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## For Further Investigation\r\n\r\n- add more/all arguments in-line with the PowerShell Hyper-V API\r\n- add acceptance tests\r\n- add API tests\r\n- terraform-style documentation\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefaanc%2Fterraform-provider-hyperv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefaanc%2Fterraform-provider-hyperv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefaanc%2Fterraform-provider-hyperv/lists"}