Skip to main content
The Cloud service provides comprehensive methods for managing Gcore cloud infrastructure resources including virtual machines, networks, storage volumes, load balancers, and Kubernetes clusters.

Getting Started

The Cloud service is accessed through the main Gcore client:
import (
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cloud"
    "github.com/G-Core/gcore-go/option"
)

client := gcore.NewClient(
    option.WithAPIKey("your-api-key"),
    option.WithCloudProjectID(projectID),
    option.WithCloudRegionID(regionID),
)

// Access cloud resources
instances := client.Cloud.Instances
networks := client.Cloud.Networks
volumes := client.Cloud.Volumes

Available Resources

The Cloud service provides access to the following resource types:

Compute Resources

Storage Resources

  • Volumes - Block storage volumes
  • Volume Snapshots - Point-in-time volume backups

Networking Resources

  • Networks - Virtual networks and subnets
  • Security Groups - Firewall rules
  • Load Balancers - Traffic distribution
  • Floating IPs - Static public IP addresses
  • Reserved Fixed IPs - Reserved private IP addresses

Container Orchestration

Other Services

  • Tasks - Asynchronous operation tracking
  • Regions - Available data center locations
  • Quotas - Resource limits and usage
  • SSH Keys - SSH key pair management
  • Secrets - Encrypted credential storage

Common Patterns

Using Project and Region Context

Most cloud operations require a project ID and region ID. You can set these globally:
client := gcore.NewClient(
    option.WithCloudProjectID(123),
    option.WithCloudRegionID(456),
)

// These will use the default project and region
instances, _ := client.Cloud.Instances.List(context.Background(), cloud.InstanceListParams{})
Or specify them per-request:
instances, _ := client.Cloud.Instances.List(context.Background(), 
    cloud.InstanceListParams{
        ProjectID: gcore.Int(123),
        RegionID: gcore.Int(456),
    },
)

Polling for Async Operations

Many cloud operations are asynchronous and return task IDs. Use the *AndPoll methods for convenience:
// Create and wait for completion
instance, err := client.Cloud.Instances.NewAndPoll(context.Background(), params)

// Delete and wait for completion
err = client.Cloud.Instances.DeleteAndPoll(context.Background(), instanceID, params)

Pagination

Use auto-paging iterators for large result sets:
iter := client.Cloud.Instances.ListAutoPaging(context.Background(), 
    cloud.InstanceListParams{
        Limit: gcore.Int(100),
    },
)

for iter.Next() {
    instance := iter.Current()
    fmt.Printf("Instance: %s\n", instance.Name)
}

if err := iter.Err(); err != nil {
    log.Fatal(err)
}

Error Handling

All methods return Go errors that can be inspected:
instance, err := client.Cloud.Instances.Get(ctx, instanceID, params)
if err != nil {
    // Handle error
    log.Printf("Failed to get instance: %v", err)
    return err
}

Next Steps

Explore specific resource types:
  • Start with Projects to organize your resources
  • Create Instances for compute workloads
  • Set up Networks for connectivity
  • Attach Volumes for persistent storage
  • Deploy Kubernetes clusters for containerized applications

Build docs developers (and LLMs) love