🛢 Simple way to create a bucket in Cloud Storage from GCP.
🔗Related content
You can find repo related in:
🐱🏍GitHub
You can connect with me in:
Resume 🧾
All this blog is using shell.
Using SDK's Google we will use tool to manage Cloud Storage. In this blog we will create a storage and upload content in it.
For more information and potential of this, click here.
Pre-Conditions:
- You need have installed SDK. You can do that following next steps Note: I set alias to use SDK like msdk. ---
1st - Set a name to bucket ✍️
We assign to a variable the name that will have bucket.
I use following command:
BUCKET_NAME="xlmriosx_bucket"
2nd - Create bucket ✅
Using SDK installed with alias like msdk I use following command to create a bucket:
- With alias:
mdsk gsutil mb -p $PROJECT_NAME -c $BUCKET_TYPE -l $REGION gs://$BUCKET_NAME
- Without alias:
docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gsutil mb -p $PROJECT_NAME -c $BUCKET_TYPE -l $REGION gs://$BUCKET_NAME
Where:
$PROJECT_NAME -> Is name of the project where you wnat instance a bucket.
$BUCKET_TYPE -> Is type of storage you want, like standard, nearline, coldline, archive.
$REGION -> Region where you want stay your storage bucket.
OUTPUT:
Creating gs://xlmriosx_bucket/...
3rd - Verify that your bucket was created ✅
We will list buckets to verify that our bucket was created:
- With alias:
docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth login
- Without alias:
msdk gsutil ls gs://$BUCKET_NAME
4th - Upload content in bucket ⬆️
We can copy content to bucket with the following command:
msdk gsutil cp $DATA gs://$BUCKET_NAME
OUTPUT:
Copying file:///$DATA
[Content-Type=X]...
- [1 files][ Y.0 B/ Y.0 B]
Operation completed over 1 objects/Y.0 B.
Where:
$DATA -> Directory or file that we want upload in the bucket.
Top comments (0)