Créer un bucket

De Wiki de Jordan LE NUFF
Sauter à la navigation Sauter à la recherche
(Page créée avec « ==Présentation== Cette page a pour objet de décrire comment créer un bucket dans Cloud Storage de GCP. ==Documentation== La documentation officielle concernant la cré… »)
 
Ligne 5 : Ligne 5 :
 
La documentation officielle concernant la création de buckets se trouve sur l'URL https://cloud.google.com/storage/docs/creating-buckets?hl=fr.
 
La documentation officielle concernant la création de buckets se trouve sur l'URL https://cloud.google.com/storage/docs/creating-buckets?hl=fr.
  
==Mise en œuvre==
+
==Avec l'interface graphique==
 
Depuis le menu de navigation principal de GCP sur la gauche, se rendre dans la section "Stockage" et cliquer sur "Cloud Storage" :
 
Depuis le menu de navigation principal de GCP sur la gauche, se rendre dans la section "Stockage" et cliquer sur "Cloud Storage" :
 
:[[Fichier:ClipCapIt-220303-162249.PNG|none|thumb|300px]]
 
:[[Fichier:ClipCapIt-220303-162249.PNG|none|thumb|300px]]
Ligne 31 : Ligne 31 :
  
 
L'étape suivante est d'y ajouter des autorisations d'accès.
 
L'étape suivante est d'y ajouter des autorisations d'accès.
 +
 +
==En ligne de commande==
 +
La commande de base à utiliser pour manipuler les buckets est <code>gsutil</code>.
 +
 +
Pour créer un bucket, lancer la commande suivante :
 +
gsutil mb -p PROJECT_ID -c STORAGE_CLASS -l BUCKET_LOCATION -b on gs://BUCKET_NAME
 +
 +
Renseigner les options comme suit :
 +
*<code>-p PROJECT_ID</code>
 +
*:où <code>PROJECT_ID</code>représente l'ID ou le numéro du projet auquel le bucket sera associé
 +
*<code>-c STORAGE_CLASS</code>
 +
*:où <code>STORAGE_CLASS</code> représente la [https://cloud.google.com/storage/docs/storage-classes classe de stockage] par défaut du bucket
 +
*<code>-l BUCKET_LOCATION</code>
 +
*:où <code>BUCKET_LOCATION</code> représente l'[https://cloud.google.com/storage/docs/locations emplacement] du bucket
 +
*<code>-b on gs://BUCKET_NAME</code>
 +
*:où <code>BUCKET_NAME</code>[https://cloud.google.com/storage/docs/uniform-bucket-level-access accès uniforme au niveau du bucket]
 +
 +
Voici l'aide à la commande <code>gsutil mb</code> :
 +
{{terminal|text=
 +
NAME
 +
  mb - Make buckets
 +
 +
 +
SYNOPSIS
 +
 +
  gsutil mb [-b (on{{!}}off)] [-c <class>] [-l <location>] [-p <project>]
 +
            [--autoclass] [--retention <time>] [--pap <setting>]
 +
            [--placement <region1>,<region2>]
 +
            [--rpo (ASYNC_TURBO{{!}}DEFAULT)] gs://<bucket_name>...
 +
 +
 +
 +
DESCRIPTION
 +
  Create one or more new buckets. Google Cloud Storage has a single namespace,
 +
  so you are not allowed to create a bucket with a name already in use by
 +
  another user. You can, however, carve out parts of the bucket name space
 +
  corresponding to your company's domain name (see "gsutil help naming").
 +
 +
  If you don't specify a project ID or project number using the -p option, the
 +
  buckets are created using the default project ID specified in your `gsutil
 +
  configuration file <https://cloud.google.com/storage/docs/boto-gsutil>`_.
 +
 +
  The -l option specifies the location for the buckets. Once a bucket is created
 +
  in a given location, it cannot be moved to a different location. Instead, you
 +
  need to create a new bucket, move the data over, and then delete the original
 +
  bucket.
 +
 +
BUCKET STORAGE CLASSES
 +
  You can specify one of the `storage classes
 +
  <https://cloud.google.com/storage/docs/storage-classes>`_ for a bucket
 +
  with the -c option.
 +
 +
  Example:
 +
 +
    gsutil mb -c nearline gs://some-bucket
 +
 +
  See online documentation for
 +
  `pricing <https://cloud.google.com/storage/pricing>`_ and
 +
  `SLA <https://cloud.google.com/storage/sla>`_ details.
 +
 +
  If you don't specify a -c option, the bucket is created with the
 +
  default storage class Standard Storage.
 +
 +
BUCKET LOCATIONS
 +
  You can specify one of the `available locations
 +
  <https://cloud.google.com/storage/docs/locations>`_ for a bucket
 +
  with the -l option.
 +
 +
  Examples:
 +
 +
    gsutil mb -l asia gs://some-bucket
 +
 +
    gsutil mb -c standard -l us-east1 gs://some-bucket
 +
 +
  If you don't specify a -l option, the bucket is created in the default
 +
  location (US).
 +
 +
Retention Policy
 +
  You can specify retention period in one of the following formats:
 +
 +
  --retention <number>s
 +
      Specifies retention period of <number> seconds for objects in this bucket.
 +
 +
  --retention <number>d
 +
      Specifies retention period of <number> days for objects in this bucket.
 +
 +
  --retention <number>m
 +
      Specifies retention period of <number> months for objects in this bucket.
 +
 +
  --retention <number>y
 +
      Specifies retention period of <number> years for objects in this bucket.
 +
 +
  Examples:
 +
 +
    gsutil mb --retention 1y gs://some-bucket
 +
 +
    gsutil mb --retention 36m gs://some-bucket
 +
 +
  If you don't specify a --retention option, the bucket is created with no
 +
  retention policy.
 +
 +
OPTIONS
 +
  --autoclass            Enables the Autoclass feature that automatically
 +
                        sets object storage classes.
 +
 +
  -b <on{{!}}off>            Specifies the uniform bucket-level access setting.
 +
                        When "on", ACLs assigned to objects in the bucket are
 +
                        not evaluated. Consequently, only IAM policies grant
 +
                        access to objects in these buckets. Default is "off".
 +
 +
  -c class              Specifies the default storage class.
 +
                        Default is "Standard".
 +
 +
  -k <key>              Set the default KMS key using the full path to the key,
 +
                        which has the following form:
 +
                        ``projects/[project-id]/locations/[location]/keyRings/[key-ring]/cryptoKeys/[my-key]``
 +
 +
  -l location            Can be any supported location. See
 +
                        https://cloud.google.com/storage/docs/locations
 +
                        for a discussion of this distinction. Default is US.
 +
                        Locations are case insensitive.
 +
 +
  -p project            Specifies the project ID or project number to create
 +
                        the bucket under.
 +
 +
  -s class              Same as -c.
 +
 +
  --retention time      Specifies the retention policy. Default is no retention
 +
                        policy. This can only be set on gs:// buckets and
 +
                        requires using the JSON API. For more details about
 +
                        retention policy see "gsutil help retention"
 +
 +
  --pap setting          Specifies the public access prevention setting. Valid
 +
                        values are "enforced" or "unspecified". When
 +
                        "enforced", objects in this bucket cannot be made
 +
                        publicly accessible. Default is "unspecified".
 +
 +
  --placement reg1,reg2  Two regions that form the cutom dual-region.
 +
                        Only regions within the same continent are or will ever
 +
                        be valid. Invalid location pairs (such as
 +
                        mixed-continent, or with unsupported regions)
 +
                        will return an error.
 +
 +
  --rpo setting          Specifies the `replication setting <https://cloud.google.com/storage/docs/turbo-replication>`_.
 +
                        This flag is not valid for single-region buckets,
 +
                        and multi-region buckets only accept a value of
 +
                        DEFAULT. Valid values for dual region buckets
 +
                        are (ASYNC_TURBO{{!}}DEFAULT). If unspecified, DEFAULT is applied
 +
                        for dual-region and multi-region buckets.}}

Version du 4 mars 2022 à 14:12

Présentation

Cette page a pour objet de décrire comment créer un bucket dans Cloud Storage de GCP.

Documentation

La documentation officielle concernant la création de buckets se trouve sur l'URL https://cloud.google.com/storage/docs/creating-buckets?hl=fr.

Avec l'interface graphique

Depuis le menu de navigation principal de GCP sur la gauche, se rendre dans la section "Stockage" et cliquer sur "Cloud Storage" :

ClipCapIt-220303-162249.PNG

Depuis le menu "Navigateur" de Cloud Storage, cliquer sur "Créer un bucket" :

Erreur lors de la création de la miniature : Fichier manquant

Donner un nom au bucket et cliquer sur "Continuer" :

Erreur lors de la création de la miniature : Fichier manquant

En fonction de la où se situent les utilisateurs du bucket et de la latence désirée, choisir le type d'emplacement et cliquer sur "Continuer" :

Erreur lors de la création de la miniature : Fichier manquant

En fonction de la fréquence d'accès aux données, choisir une classe de stockage et cliquer sur "Continuer" :

Erreur lors de la création de la miniature : Fichier manquant

Choisir le type de contrôle d'accès désiré et cliquer sur "Continuer" :

Erreur lors de la création de la miniature : Fichier manquant

Choisir un outil de protection et/ou le chiffrement des données au besoin et cliquer sur "Créer" pour créer le bucket :

Erreur lors de la création de la miniature : Fichier manquant

Le bucket est créé. Les détails de ce dernier s'affiche alors :

Erreur lors de la création de la miniature : Fichier manquant

L'étape suivante est d'y ajouter des autorisations d'accès.

En ligne de commande

La commande de base à utiliser pour manipuler les buckets est gsutil.

Pour créer un bucket, lancer la commande suivante :

gsutil mb -p PROJECT_ID -c STORAGE_CLASS -l BUCKET_LOCATION -b on gs://BUCKET_NAME

Renseigner les options comme suit :

  • -p PROJECT_ID
    PROJECT_IDreprésente l'ID ou le numéro du projet auquel le bucket sera associé
  • -c STORAGE_CLASS
    STORAGE_CLASS représente la classe de stockage par défaut du bucket
  • -l BUCKET_LOCATION
    BUCKET_LOCATION représente l'emplacement du bucket
  • -b on gs://BUCKET_NAME
    BUCKET_NAMEaccès uniforme au niveau du bucket

Voici l'aide à la commande gsutil mb :

Putty icon.png Console SSH