Skip to content

arnaud-dezandee/vagrant-box-gcs

Repository files navigation

Vagrant Box Google Cloud Storage (GCS)

Gem Version

This is a Vagrant 2.2.0+ plugin that adds the ability to download boxes from Google Compute Storage (GCS).

Installation

$ vagrant plugin install vagrant-box-gcs

Usage

Only the gs:// protocol shorthand is supported

The plugin supports fetching compatible manifest file of versioned boxes repository. See packer-vagrant-box-gcs to create one.

From versioned box:

$ vagrant box add gs://my-bucket/my-org/my-box-manifest.json

The box update command line is available when using manifest

$ vagrant box update --box my-org/my-box
# Vagrantfile
Vagrant.configure('2') do |config|
  config.vm.box     = 'my-org/my-box'
  config.vm.box_url = 'gs://my-bucket/my-org/my-box-manifest.json'
end

From simple box:

$ vagrant box add gs://my-bucket/my-org/my-box/virtualbox.box
# Vagrantfile
Vagrant.configure('2') do |config|
  config.vm.box_url = 'gs://my-bucket/my-org/my-box/virtualbox.box'
end

Authentication

Authenticating with Google Cloud services requires at most one JSON file. Vagrant will look for credentials in the following places, preferring the first location found:

  1. A JSON file (Service Account) whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.

  2. A JSON file in a location known to the gcloud command-line tool. (gcloud auth application-default login creates it)

    On Windows, this is:

    %APPDATA%/gcloud/application_default_credentials.json
    

    On other systems:

    $HOME/.config/gcloud/application_default_credentials.json
    
  3. On Google Compute Engine and Google App Engine Managed VMs, it fetches credentials from the metadata server. (Needs a correct VM authentication scope configuration)

Auto-install

Auto-install with some shell in your Vagrantfile:

# Vagrantfile
unless Vagrant.has_plugin?('vagrant-box-gcs')
  system('vagrant plugin install vagrant-box-gcs') || exit!
  exit system('vagrant', *ARGV)
end

Vagrant.configure('2') do |config|
  config.vm.box_url = 'gs://my-bucket/my-org/my-box/virtualbox.box'
  # ...
end

Related