google-cloud-compute: GCP Client for Haskell

[ library, mit, web ] [ Propose Tags ] [ Report a vulnerability ]

GCP Compute client for Haskell.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 1.1.0.0
Change log CHANGELOG.md
Dependencies aeson (<3), base (>=4.7 && <5), bytestring (>=0.9.1.4), containers (>=0.6 && <1), google-cloud-common (>=1.1.0.0 && <1.2.0.0), http-conduit (>=2.2 && <2.4), text (>=1.2 && <3) [details]
License MIT
Copyright 2025 tushar
Author tushar
Maintainer tusharadhatrao@gmail.com
Category Web
Home page https://github.com/tusharad/google-cloud-haskell#readme
Bug tracker https://github.com/tusharad/google-cloud-haskell/issues
Source repo head: git clone https://github.com/tusharad/google-cloud-haskell
Uploaded by tusharad at 2025-09-11T14:11:57Z
Distributions NixOS:0.1.0.0
Downloads 12 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for google-cloud-compute-1.1.0.0

[back to package description]

google-cloud-compute

Haskell idiomatic client for Google Cloud Platform Compute service.

Full docs are available at https://github.com/tusharad/google-cloud-haskell

Installation

  • Cabal: add to your .cabal
    • build-depends: google-cloud-compute == 1.1.0.0
  • Stack: add to your package.yaml
    • dependencies: - google-cloud-compute == 1.1.0.0

This package depends on google-cloud-common for auth and HTTP helpers.

Authentication

Authentication is handled by google-cloud-common and follows this order:

  1. Use GOOGLE_APPLICATION_CREDENTIALS to load a Service Account JSON and exchange a signed JWT for an access token.
  2. Otherwise, use the Compute metadata server (suitable for GCE/GKE).

Examples

Below are minimal examples. See examples/ in the repo for more.

{-# LANGUAGE OverloadedStrings #-}

import Google.Cloud.Compute.Instance

-- List instances
listInstancesExample :: IO ()
listInstancesExample = do
  let projectId = "my-gcp-project"
      zone = "us-central1-a"
      query = defaultListInstancesQuery
  result <- listInstances projectId zone (Just query)
  case result of
    Left err -> putStrLn ("Error: " <> err)
    Right instances -> print instances

-- Create an instance
createInstanceExample :: IO ()
createInstanceExample = do
  let projectId = "my-gcp-project"
      zone = "us-central1-a"
      instanceName = "my-instance"
      machineType = "e2-medium"
      ops = defaultInsertInstanceOps projectId zone instanceName machineType
  res <- insertInstance projectId zone ops (Just (InsertInstanceQuery (Just "req-123") Nothing))
  case res of
    Left err -> putStrLn ("Create error: " <> err)
    Right _  -> putStrLn "Create initiated"

-- Start/Stop an instance
startStopExample :: IO ()
startStopExample = do
  let projectId = "my-gcp-project"
      zone = "us-central1-a"
      name = "my-instance"
      reqId = defaultRequestIdQuery "req-456"
  _ <- startInstance projectId zone name (Just reqId)
  _ <- stopInstance  projectId zone name (Just reqId)
  putStrLn "Start/Stop submitted"

Additional modules:

  • Google.Cloud.Compute.Disk
  • Google.Cloud.Compute.Firewall
  • Google.Cloud.Compute.Network

License

MIT © Contributors