Code Monkey home page Code Monkey logo

google-cloud-storage-intro's Introduction

google-cloud-storage-intro

Intro Google Cloud Storage Lab. Learn how to perform common tasks using gsutil.

Final Environment

Getting Started

  1. Ensure the Following APIs are enabled (enable with gcloud services enable [service]):

    • iam.googleapis.com
    • storage-component.googleapis.com
  2. Ensure the default Google APIs service account (used by deployment manager) has permission to create roles:

    gcloud projects add-iam-policy-binding [PROJECT_ID] \
    --member serviceAccount:[PROJECT_NUMBER]@cloudservices.gserviceaccount.com  \
    --role roles/iam.roleAdmin

    You can use gcloud list projects to get the project ID and number.

  3. Deploy the deployment manager config in the infrastructure directory:

    gcloud deployment-manager deployments create lab --config infrastructure/deployment.yaml
  4. Bind the Lab role to the student user or group

    • In macOS/Linux:

      member="[GROUP_OR_USER]"
      project_id=$(gcloud config list --format 'value(core.project)')
      role=$(gcloud iam roles list --project $project_id \
                                   --filter "name:projects/$project_id/roles/studentrole*" \
                                   --format "value(name)")
      gcloud projects add-iam-policy-binding $project_id \
      --member $member  \
      --role $role
    • In Windows (PowerShell):

      $member = "[GROUP_OR_USER]"
      $project_id = gcloud config list --format 'value(core.project)'
      $role = gcloud iam roles list --project $project_id `
                                    --filter "name:projects/$project_id/roles/studentrole*" `
                                    --format "value(name)"
      gcloud projects add-iam-policy-binding $project_id `
      --member $member  `
      --role $role

    An example of [GROUP_OR_USER] is user:[email protected].

Following Along

  1. Start a Google Cloud Shell session.

  2. Create a bucket (replace [BUCKET_NAME] with the desired name):

    bucket_name=[BUCKET_NAME]
    gsutil mb -c multi_regional -l US gs://$bucket_name
  3. Upload the Cloud Shell README to the bucket:

    gsutil cp -s regional README-cloudshell.txt gs://$bucket_name/    
  4. Perform a detailed listing of the bucket to confirm the storage class and other details:

    gsutil ls -L gs://$bucket_name/* | more
  5. Enable versioning on the bucket:

    gsutil versioning set on gs://$bucket_name
  6. Overwrite the README and observe the new Generation number for the object:

    gsutil cp README-cloudshell.txt gs://$bucket_name/
    gsutil ls -L gs://$bucket_name/* | more
  7. List all available versions for the object:

    gsutil ls -a gs://$bucket_name/plan.txt

    Note the generation number is appended to identify different versions of the object.

Tearing Down

When finished, remove the GCP resources with:

gsutil rm -r gs://$bucket_name
gsutil rb gs://$bucket_name
gcloud projects remove-iam-policy-binding [PROJECT_ID] \
    --member [GROUP_OR_USER]  \
    --role projects/[PROJECT_ID]/roles/studentrole
gcloud deployment-manager deployments delete lab

google-cloud-storage-intro's People

Contributors

lrakai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.