{"id":15171866,"url":"https://github.com/determinatesystems/terraform-provider-hydra","last_synced_at":"2025-05-12T15:03:03.429Z","repository":{"id":38267755,"uuid":"360967543","full_name":"DeterminateSystems/terraform-provider-hydra","owner":"DeterminateSystems","description":"Declaratively configure your Hydra server with Terraform.","archived":false,"fork":false,"pushed_at":"2025-01-08T18:23:03.000Z","size":15578,"stargazers_count":45,"open_issues_count":8,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-31T07:23:05.297Z","etag":null,"topics":["hydra","nix","nixos","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":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeterminateSystems.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":"2021-04-23T18:04:11.000Z","updated_at":"2025-01-08T18:23:06.000Z","dependencies_parsed_at":"2024-12-17T17:43:31.372Z","dependency_job_id":null,"html_url":"https://github.com/DeterminateSystems/terraform-provider-hydra","commit_stats":{"total_commits":140,"total_committers":6,"mean_commits":"23.333333333333332","dds":0.4285714285714286,"last_synced_commit":"8a16bc7712c8f8aa4245bbb3d12ee60fb0c7dab4"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fterraform-provider-hydra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fterraform-provider-hydra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fterraform-provider-hydra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fterraform-provider-hydra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeterminateSystems","download_url":"https://codeload.github.com/DeterminateSystems/terraform-provider-hydra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238059009,"owners_count":19409607,"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":["hydra","nix","nixos","terraform","terraform-provider"],"created_at":"2024-09-27T09:20:56.735Z","updated_at":"2025-02-10T05:10:34.349Z","avatar_url":"https://github.com/DeterminateSystems.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-provider-hydra\n\nThe Terraform Hydra provider is a plugin for Terraform that allows for\ndeclarative management of a [Hydra] instance. You can find it on the [Terraform\nRegistry].\n\n## Requirements\n\nTo use this provider, you will need the following:\n\n* [Terraform] 0.13+\n* A Hydra instance running [commit\n`5b6b826`](https://github.com/NixOS/hydra/commit/5b6b8261fc0571c4ee678cbe829ba07ed9372ef0)\nor later\n\n\u003e **NOTE**: You *can* use this provider with [commit\n\u003e `6e53767`](https://github.com/NixOS/hydra/commit/6e537671dfa21f89041cbe16f0b461fe44327038)\n\u003e (at the absolute earliest), but it has a known issue where some internal\n\u003e fields were not nullified, leading to state differences between Hydra and\n\u003e Terraform, and is *not* recommended.\n\n## Getting started\n\nTo get started with this provider, you'll need to create a configuration file\nthat will tell Terraform to use this provider. This will look something like the\nfollowing snippet:\n\n```terraform\nterraform {\n  required_providers {\n    hydra = {\n      version = \"~\u003e 0.1\"\n      source  = \"DeterminateSystems/hydra\"\n    }\n  }\n}\n```\n\nAfter that's done, you'll need to specify where your Hydra instance can be\nreached and provide credentials for this provider to be able to work its magic:\n\n\u003e **NOTE:** Hard-coded credentials are not recommended, so while it is possible\nto use them (just uncomment the `username` and `password` items and fill them in\nwith valid values), you are urged to use the `HYDRA_USERNAME` and\n`HYDRA_PASSWORD` environment variables.\n\n```terraform\nprovider \"hydra\" {\n  host = \"https://hydra.example.com\"\n  # username = \"alice\"\n  # password = \"foobar\"\n}\n```\n\nNow that you can connect to Hydra, it's time to create a project with the\n[`hydra_project` resource](./docs/resources/project.md):\n\n```terraform\nresource \"hydra_project\" \"nixpkgs\" {\n  name         = \"nixpkgs\"\n  display_name = \"Nixpkgs\"\n  description  = \"Nix Packages collection\"\n  homepage     = \"https://nixos.org/nixpkgs\"\n  owner        = \"alice\"\n  enabled      = true\n  visible      = true\n}\n```\n\nYou can attach a jobset to this project with the [`hydra_jobset`\nresource](./docs/resources/jobset.md):\n\n\u003e **NOTE:** The `check_interval` is 0 for this example to prevent Hydra from\nstarting an evaluation on the entirety of Nixpkgs. Change this to a non-zero\nvalue if you would like to tell Hydra it can start evaluating this jobset.\n\n```terraform\nresource \"hydra_jobset\" \"trunk-flake\" {\n  project     = hydra_project.nixpkgs.name\n  state       = \"enabled\"\n  visible     = true\n  name        = \"trunk-flake\"\n  type        = \"flake\"\n  description = \"master branch\"\n\n  flake_uri = \"github:NixOS/nixpkgs/master\"\n\n  check_interval    = 0\n  scheduling_shares = 3000\n  keep_evaluations  = 3\n\n  email_notifications = true\n  email_override      = \"example@example.com\"\n}\n```\n\nThat's it for the basic usage of this provider!\n\nYou may also want to check out the example configurations inside [the\n`examples/` directory](./examples/).\n\n### Importing from an existing Hydra instance\n\nYou can migrate from a hand-configured Hydra to Terraform-managed configuration\nfiles using our included generator,\n[`./tools/generator.sh`](./tools/generator.sh).\n\nThe generator enumerates the server's projects and jobsets, generating a `.tf`\nfile for each project. The generator also produces a script of `terraform\nimport` commands.\n\nThe workflow is:\n\n1. Execute `generator.sh`\n2. Commit the generated `.tf` files to your repository\n3. Execute the generated `terraform import` script\n4. Discard the `terraform import` script, as it should not be necessary anymore\n\nYour Terraform network and state file will now have up-to-date data for all of\nyour existing project and jobset resources, and a `terraform plan` should report\nno differences were detected.\n\n```shell\n$ cd tools\n$ nix-shell\n# Usage: generator.sh \u003cserver-root\u003e \u003cout-dir\u003e \u003cimport-file\u003e\n#\n#     Arguments:\n#         \u003cserver-root\u003e    The root of the Hydra server to import projects and jobsets from.\n#         \u003cout-dir\u003e        The directory to output generated Terraform configuration files to.\n#         \u003cimport-file\u003e    Where to write the generated list of 'terraform import' statements.\nnix-shell$ ./generator.sh hydra.example.com outdir generated-tf-import.sh\n```\n\n## Development\n\nIn addition to the dependencies for using this provider, hacking on this\nprovider also requires the following:\n\n* [Go] 1.15+\n* [`oapi-codegen`]\n\n### Running locally\n\nThis assumes a running instance of Hydra is available.\n\n```shell\n$ nix-shell\nnix-shell$ make install\nnix-shell$ cd examples/default\nnix-shell$ terraform init \u0026\u0026 terraform plan\n```\n\n### Regenerating API bindings\n\nThis will fetch the latest `hydra-api.yaml` from Hydra and generate API bindings\nagainst that specification.\n\n```shell\n$ nix-shell\nnix-shell$ make api\n```\n\n### Running acceptance tests locally\n\n**NOTE:** You should use a throwaway Hydra instance to prevent anything\nunexpected happening.\n\n```shell\n$ nix-shell\nnix-shell$ HYDRA_HOST=http://0.0.0.0:63333 HYDRA_USERNAME=alice HYDRA_PASSWORD=foobar make testacc\n```\n\n## Contributing\n\nPull requests are welcome. When submitting one, please follow the checklist in\nthe template to ensure everything works properly.\n\nThe typical contribution workflow is as follows:\n\n1. Make your change\n1. Format it with `make fmt` (requires [`goimports`])\n1. Verify it builds with `make build`\n1. Install it with `make install`\n1. Spin up a local Hydra server to test with (see the Hydra documentation on\n[Executing Hydra During Development](https://github.com/NixOS/hydra/blob/6e537671dfa21f89041cbe16f0b461fe44327038/README.md#executing-hydra-during-development))\n1. Extend one of the [examples](./examples/) so that it will exercise your\nchange (or write your own example!)\n1. Remove the `.terraform.lock.hcl` file (if it exists) and run `terraform init\n\u0026\u0026 terraform apply`\n1. Once everything looks good, write a test for your change\n1. Commit and open a pull request (be sure to follow the checklist in the\ntemplate)\n\n## FAQ\n\n#### Q. Does this provider support Basic Authentication?\n\nA. Yes! Just set the `HYDRA_HOST` environment variable to e.g.\n`https://user:password@hydra.example.com`. You can also set the `host` in your\nconfiguration to this, but hard-coded credentials are insecure and not\nrecommended.\n\n## License\n\n[MPL-2.0](LICENSE)\n\n[Hydra]: https://github.com/NixOS/hydra\n[Terraform]: https://www.terraform.io/downloads.html\n[Go]: https://golang.org/doc/install\n[`oapi-codegen`]: https://github.com/deepmap/oapi-codegen\n[`goimports`]: https://pkg.go.dev/golang.org/x/tools/cmd/goimports\n[Terraform Registry]: https://registry.terraform.io/providers/DeterminateSystems/hydra/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fterraform-provider-hydra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeterminatesystems%2Fterraform-provider-hydra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fterraform-provider-hydra/lists"}