Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying from Hydra with Terraform #72

Open
grahamc opened this issue Oct 20, 2021 · 0 comments
Open

Deploying from Hydra with Terraform #72

grahamc opened this issue Oct 20, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@grahamc
Copy link
Member

grahamc commented Oct 20, 2021

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

@grahamc grahamc added the enhancement New feature or request label Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant