Open
Description
Description
It'd be slick to implement the concepts from https://determinate.systems/posts/hydra-deployment-source-of-truth in Terraform.
Specifically:
- Get the build information for a job's latest successful build, and latest successful build from a completed evaluation
- Get information about a specific constituent of an aggregate job
New or Affected Resource(s)
data "hydra_job"
data "hydra_job_aggregate_constituent"
Potential Terraform Configuration
Deploying from a job:
data "hydra_job" "latest_myapp" {
project = "myapp"
jobset = "main"
job = "myapp"
wait_for_all_jobs = true # latest-successful ... consider a better name?
}
resource "aws_instance" "web" {
# ...
provisioner "remote-exec" {
command = "nix-env -p /nix/var/nix/profiles/myapp --set '${data.hydra_job.latest_myapp.outputs.out.path}'"
}
}
Deploy the constituent of an aggregate job:
data "hydra_job_aggregate_constituent" "serverconfig" {
project = "myapp"
jobset = "main"
job = "release_gate"
constituent = "serverconfig"
wait_for_all_jobs = true
}
resource "aws_instance" "web" {
# ...
provisioner "remote-exec" {
inline = [
"nix-env --profile /nix/var/nix/profiles/system --set '${data.hydra_job_aggregate_constituent.serverconfig.outputs.out.path}'",
"/nix/var/nix/profiles/system/bin/switch-to-configuration switch",
]
}
}
References
- Example: https://determinate.systems/posts/hydra-deployment-source-of-truth
- Improving the constituents API: The Constituents API is Awkward NixOS/hydra#1046