No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Paul Rossman 185028a734 Merge pull request #1 from mbrukman/fix-readme
Remove extra indentation for code blocks.
2015-02-23 17:22:13 -08:00
attributes initial commit 2014-06-03 22:40:41 -07:00
libraries initial commit 2014-06-03 22:40:41 -07:00
providers foodcritic updates 2014-06-05 14:41:01 -07:00
recipes foodcritic updates 2014-06-05 14:41:01 -07:00
resources added object get 2014-06-04 22:15:08 -07:00
.gitignore Initial commit 2014-06-03 12:08:30 -07:00
CHANGELOG.md initial commit 2014-06-03 22:40:41 -07:00
LICENSE Initial commit 2014-06-03 12:08:30 -07:00
metadata.rb improved error handling, updated readme 2014-06-04 15:27:32 -07:00
README.md Remove extra indentation for code blocks. 2015-02-20 22:09:39 -05:00

Google Cloud Storage Cookbook LWRP

Description

This cookbook provides libraries, resources and providers to configure and manage Google Cloud Storage components. The currently supported GCS resources are:

  • bucket (bucket)
  • object (object)

Requirements

Requires fog ruby gem to interact with GCS.

Authorizing Setup

In order to use the Google Cloud Storage cookbook, you will first need to have a Google Cloud project. Once your project has been created, log in to the [Google Developers Console] (https://console.developers.google.com/project) and select your project. From the Google Developers Console, on the left side of the page, click "APIs & auth" then the "Credentials" sub menu. At the bottom of the page, click "Return to original console". This will redirect you to the "Google APIs Console". From the new menu on the left side of the page, click on "Google Cloud Storage" Unless you've already enabled "Interoperable Access" you'll see a button towards the bottom of the page. Click that button to enable "Interoperable Access". Finally, click the new "Interoperable Access" sub menu on the left side of the page. Your "Interoperable Storage Access Keys" will now be listed.

% knife  data bag show gcs credentials
{
  "access_key_id": "AABBCCDDEE",
  "secret_access_key": "abcdefg23456789+0"
}

This can be loaded in a recipe with:

gcs = data_bag_item("gcs", "credentials")

And to access the values:

gcs['access_key_id']
gcs['secret_access_key']

Resources and Providers

This cookbook provides a resource and corresponding provider.

object.rb

Manage GCS objects with this resource.

Actions:

  • get - download an object.
  • put - upload an object.
  • delete - delete object.
  • copy - copy an object from one bucket to another.

bucket.rb

Manage GCS buckets with this resource.

Actions:

  • put - create a bucket.
  • delete - delete a bucket.

Usage

object create

This will copy a local file to GCS with default private permissions set.

gcs_object "my_file" do
  access_key_id gcs['access_key_id']
  secret_access_key gcs['secret_access_key']
  bucket_name "my_bucket"
  local_path "/path/to/my_file"
  action :put
end

object copy

This will copy an object from one bucket to another. By default, the target object name will be the same as source unless specified with the optional target_bucket_name.

gcs_object "my_file" do
  access_key_id gcs['access_key_id']
  secret_access_key gcs['secret_access_key']
  source_bucket_name "my_bucket"
  target_bucket_name "my_other_bucket"
  action :copy
end

License and Authors

Copyright 2014, Google, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.